songvan
songvan

Reputation: 379

How to obtain exact input value of double in QDoubleSpinBox?

I need to get the exact input value of double spin box. I set 8 decimal digit for my Spinbox. When I type 0,6000000 what I get in the debug is 0,59999999999998 as in the picture (sometimes it is 0,6000000000002).

pic1

I tried to convert this value to 0,60000000 using QString::number and convert it again to double. What I receive is the old value again (0,59999999999998).

enter image description here But when I print these values out, it prints 0,60000000.

Because I have my calculation after that, so I need the exact input value, otherwise my calculation will be wrong. In this case I should become exact 0,60000000). How can I do that?

Upvotes: 0

Views: 814

Answers (0)

Related Questions