I have :
There is no exact representation of 36.09999999 in binary floating point.
36.0999999999 as long double:
Before: 36.09999999989999999727707802321674535050988197326660156250000000000000000000000000
Value: 36.09999999990000000074652497517035953933373093605041503906250000000000000000000000
After: 36.09999999990000000421597192712397372815757989883422851562500000000000000000000000
36.0999999999 as double:
Before: 36.099999999899992531027237419039011001586914062500000000000000
Value: 36.099999999899999636454595020040869712829589843750000000000000
After: 36.099999999900006741881952621042728424072265625000000000000000
36.0999999999 as float:
Before: 36.099994659423828125000000000000000000000000000000000000000000
Value: 36.099998474121093750000000000000000000000000000000000000000000
After: 36.100002288818359375000000000000000000000000000000000000000000
When I do :
char cf[25];
sprintf(cf,"%0.03lf", f);
I get : 36.100
There is no exact representation of 36.100 in binary floating point.
36.100 as long double:
Before: 36.09999999999999999514277426726494013564661145210266113281250000000000000000000000
Value: 36.09999999999999999861222121921855432447046041488647460937500000000000000000000000
After: 36.10000000000000000208166817117216851329430937767028808593750000000000000000000000
36.100 as double:
Before: 36.099999999999994315658113919198513031005859375000000000000000
Value: 36.100000000000001421085471520200371742248535156250000000000000
After: 36.100000000000008526512829121202230453491210937500000000000000
36.100 as float:
Before: 36.099994659423828125000000000000000000000000000000000000000000
Value: 36.099998474121093750000000000000000000000000000000000000000000
After: 36.100002288818359375000000000000000000000000000000000000000000
There is no exact representation of 36.099 in binary floating point.
36.099 as long double:
Before: 36.09899999999999999772404279951842909213155508041381835937500000000000000000000000
Value: 36.09900000000000000119348975147204328095540404319763183593750000000000000000000000
After: 36.09900000000000000466293670342565746977925300598144531250000000000000000000000000
36.099 as double:
Before: 36.098999999999989540810929611325263977050781250000000000000000
Value: 36.098999999999996646238287212327122688293457031250000000000000
After: 36.099000000000003751665644813328981399536132812500000000000000
36.099 as float:
Before: 36.098995208740234375000000000000000000000000000000000000000000
Value: 36.098999023437500000000000000000000000000000000000000000000000
After: 36.099002838134765625000000000000000000000000000000000000000000