Floats and Decimal Rounding
I have a float being called from a SQL row which has the value of 5.05 but it is apparently 5.0499999 when it is stored in the float I have made. How can I make it so that is stored as 5.05 not 5.0499999.
|
Re: Floats and Decimal Rounding
|
Re: Floats and Decimal Rounding
hmmm , flaot round will round the flaot off to an interger value . but in order todo what you want im not sure what you would do . except maybee re-assig the flaot the real value you wanted .
4.049 = 4.05 ??? or something like that :wink: |
Re: Floats and Decimal Rounding
Quote:
Quote:
|
Re: Floats and Decimal Rounding
so i guess like a said the other option is assignment.
Code:
|
Re: Floats and Decimal Rounding
Quote:
|
Re: Floats and Decimal Rounding
is there a good way to fix this problem ?:|
|
Re: Floats and Decimal Rounding
No, pawn uses the IEEE double floating point percision method for using floats. It basically creates a sliding window for binary to change float values, however you loose percision with this as shown here (but this is really the only method pawn can use, since the only data type it really has is a cell).
edit Look at that link a couple of posts above. |
Re: Floats and Decimal Rounding
hmmm , that seems like a horable flaw on the points of compuphase to make a reliable flaoting point system with any accuracy. so the only way to deal with this is to over compinsate huh? thats interesting though :wink:
|
Re: Floats and Decimal Rounding
They really didn't have a choice, everything revovles around the cell, unless you want to take a year of your life to redesign everything to implement real data types :p.
|
| All times are GMT -4. The time now is 07:00. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.