Boris Belovic wrote:@1 I am using float because of our interface design (which I admit is poor). Internally, in method of this interface I am using BigDecimal for computation, but I have to return float value from methods. So, using BigDecimals I have computed value of 11013672.7100 and now I need to convert it to corresponding float value. But it seems that the BigDecimal's value and float value (value after conversion) differs.
@2 I didn't know that. So how should I correctly display floats?
Boris Belovic wrote:@ Jeff I know, but using BigDecimal I have computed the value 11013672.71, the thing is how to convert it to correct float value.
To me it seems the value after conversion is rounded to 11013673.
Boris Belovic wrote:@ Jeff I know, but using BigDecimal I have computed the value 11013672.71, the thing is how to convert it to correct float value. To me it seems the value after conversion is rounded to 11013673.
Steve
Jeff Verdegan wrote:
If you think about it for a minute, you'll realize that there have to be some int values that cannot be stored in float, and that if you're trying to count by +1 using float, you will have to skip several int values at some point.
Boris Belovic wrote:@1 I am using float because of our interface design (which I admit is poor). Internally, in method of this interface I am using BigDecimal for computation, but I have to return float value from methods. So, using BigDecimals I have computed value of 11013672.7100 and now I need to convert it to corresponding float value. But it seems that the BigDecimal's value and float value (value after conversion) differs.
"Leadership is nature's way of removing morons from the productive flow"  Dogbert
Articles by Winston can be found here
You are a bit over‑optimistic about the precision of floats. IEEE754 or whatever uses 1 digit for sign, 8 digits as exponent and 24 digits as mantissa. 24 × log(2) = 7.22, so you get at best 7¼ digits in decimal.Jeff Verdegan wrote: . . . 32 digits of decimal precision (31 on either side of 0) corresponds to somewhat less than 10 digits of decimal precision. . . .
Campbell Ritchie wrote:
You are a bit over‑optimistic about the precision of floats. IEEE754 or whatever uses 1 digit for sign, 8 digits as exponent and 24 digits as mantissa. 24 × log(2) = 7.22, so you get at best 7¼ digits in decimal.Jeff Verdegan wrote: . . . 32 digits of decimal precision (31 on either side of 0) corresponds to somewhat less than 10 digits of decimal precision. . . .
And 1 + 8 + 24 = 33. I know. It is supposed to add up to 33.
I don’t think you did.Jeff Verdegan wrote: . . .
Hope that didn't cause any further confusion.
please buy this thing and then I get a fat cut of the action:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filleradvertising
