Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7501051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:24:23+00:00 2026-05-29T20:24:23+00:00

In Java BigDecimal class contains values as A*pow(10,B) where A is 2’s complement which

  • 0

In Java BigDecimal class contains values as A*pow(10,B) where A is 2’s complement which non-fix bit length and B is 32bit integer.

In C# Decimal contains values as pow (–1,s) × c × pow(10,-e) where the sign s is 0 or 1, the coefficient c is given by 0 ≤ c < pow(2,96) , and the scale e is such that 0 ≤ e ≤ 28 .

And i want to convert Java BigDecimal to Something like c# Decimal in JAVA.
Can you help me .

I have some thing like this

class CS_likeDecimal
{
     
    private int hi;// for 32bit most sinificant bit of c 
    private int mid;// for 32bit in the middle  
    private int lo;// for 32 bit the last sinificant bit

    .....
    public CS_likeDecimal(BigDecimal data)
    {
                ....

    }

}

In fact I found this What's the best way to represent System.Decimal in Protocol Buffers?.

it a protocol buffer for send c# decimal ,but in the protobuff-net project use this to send message between c# (but i want between c# and JAVA)

message Decimal {
  optional uint64 lo = 1; // the first 64 bits of the underlying value
  optional uint32 hi = 2; // the last 32 bis of the underlying value
  optional sint32 signScale = 3; // the number of decimal digits, and the sign

}

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:24:24+00:00Added an answer on May 29, 2026 at 8:24 pm

    the Decimal I use in protobuf-net is primarily intended to support the likely usage of protobuf-net being used at both ends of the pipe, which supports a fixed range. It sounds like the range of the two types in discussion is not the same, so: are not robustly compatible.

    I would suggest explicitly using an alternative representation. I don’t know what representations are available to Java’s BigDecimal – whether there is a pragmatic byte[] version, or a string version.

    If you are confident that the scale and range won’t be a problem, then it should be possible to fudge between the two layouts with some bit-fiddling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that BigDecimal is recommended best practice for representing monetary values in Java.
BigDecimal is a class in the java.math package that has a lot of benefits
I'm running into a strange java bug using the intValue() from the BigDecimal class.
Consider the simple test class: import java.math.BigDecimal; /** * @author The Elite Gentleman *
scala.math.ScalaNumber is a Java file which looks like this: public abstract class ScalaNumber extends
How is it that Java's BigDecimal can be this painful? Double d = 13.3D;
I'm converting an algorithm I wrote in Java to Objective-C. In java the BigDecimal
(Java question) If I reference a field in an inner class, does this cause
Java SE 6 (64 bit only) is now on OS X and that is
I have a java class that I use to create a text file from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.