#### preface

If you want good answer post good question, and explain "how did you know the actual values of a and b". Otherwise all our work is about psychology reverse engineering, not programming.

#### First conceptual error

Computer normally use binary aritmetic, not decimal. 123.07 is a "constant literal" the compiler let you type for your convenience, but, internally, it is converted on compilation to the nearest binary floating-point representation the better fits a

`double `

variable. Exact decimal numbers are not necessarily exact binary number, for the very simple reason that 10 is not a power of 2. In your case, what is stored is probably something like `0,961484375 * 2<sup>7</sup>`

, where 0,961484375 must be rounded to the nearest binary representation.So don't assume a float or double variable store exactly the value you write in decimal: a small round happens just at that point.

#### Second conceptual error

Exact binary floating point values don't necessarily convert into exact decimal numbers for the simple reason that 2 is not a log

_{2}(10). After a decimal-to-binary and binary-to-decimal your 123.07 will probably looks like

123.0699999999999999999

But when you print it, the output function you use (that you didn't tell us about) have to let this thing to fit a given length and precision. If these "parameters" for whatever reason you didn't make us aware of, are set to "4 meaningful digits", you got 123.1.

But this is the same for both

`a`

and `b`

(just try to print them both ...)
even that shows 123.07 123.1

`double`

values here given their inherent inaccuracy. If you are using these for financial calculations then your answers will not be correct in many cases. Floating point (and double) numbers allow very wide precision but at the cost of accuracy, and should be avoided in most cases.