vb.net:
On Feb 5, 4:59 am, "Steve Lloyd" <steve-remo...@-spam-
[quoted text, click to view] stevelloyd.co.uk> wrote:
> Hi,
>
> Can anyone please explain this rounding error on a windows forms project.
> I take an input and need to convert from a percentage to a decimal so i do:
> dim result as double = cdbl(textbox.text) / 100
>
> when 9.85 is entered into the text box "result" is calcualted as
> 0.09849999999999999.
>
> For debugging i changed it to cdbl(textbox.text) / 1000 and also /10. both
> of these gave the accurate answers, 0.00985 and 0.985 respectively.
>
> Any ideas?
>
> Thanks for any help
>
> Steve.
It all has to do with the accuracy of doubles and there isn't too much
you can do about it. You might do some searching for the exact "whys",
this topic has been covered numerous times on most programming
newsgroups.
Thanks,