Prevent rounding

Hello All,

I am sure I am missing something, but I have a variable defined as a double which contains the value: 99.9999999999999858
I just want to display that value, but every time I put it in a string it gets rounded up to 100.
So I tried formatting it like this:

Dim strPct As String Dim KidPct As Double KidPct = 99.9999999999999858 strPct = format(KidPct,"##0.####")

~ I really only need the numbers to the left of the decimal and the first four to the right of the decimal. But I want/need them without any rounding.
Ideally I would like to display: 99.9999

Any idea where I am going awry?

Thanks!

This function: http://documentation.xojo.com/index.php/Floor if you read the bottom of it allows rounding to a certain amount of decimal places. Double appears to round to the nearest whole number automatically in most cases.

You’re not. It’s just not designed to do what you want. You could supply a format string to get the whole long number and then use regex or mid and left to take only what you want if it.

strPct = format(floor(kidpct*10e3)/10e3,"##0.####")

Thanks Guys ~

Derek I read the floor function, but must have missed that; I will go back and re-read it. Thanks!

Greg thanks for letting me know it wasn’t me and offering a suggestion to work through it.

Dave ~ your code worked w/o any issues! Thank you!