Problem with floatstr (inaccurate value)
#1

I did not face with this problem before but, when I use floatstr it returns inaccurate value.
For example:
Код:
printf("floatstr -1772.8328 result is: %f", floatstr("-1772.8328"));
printf("floatstr 1555.17 result is: %f", floatstr("1555.17"));
Quote:

floatstr -1772.8328 result is: -1772.832763
floatstr 1555.17 result is: 1555.170043

How to solve this problem? (If the full code needed - tell me)

Using 0.3e server, coding a filterscript.
Includes: mysql, zcmd, cstl
Plugins: mysql, cstl
Reply
#2

You can try this (haven't tested):
pawn Код:
printf("floatstr -1772.8328 result is: %.4f", floatstr("-1772.8328"));
printf("floatstr 1555.17 result is: %.2f", floatstr("1555.17"));
This makes the float only have 4 and 2 decimal places (respectively)
Reply
#3

Quote:
Originally Posted by Yuryfury
Посмотреть сообщение
You can try this (haven't tested):
pawn Код:
printf("floatstr -1772.8328 result is: %.4f", floatstr("-1772.8328"));
printf("floatstr 1555.17 result is: %.2f", floatstr("1555.17"));
This makes the float only have 4 and 2 decimal places (respectively)
There is a big number of floats in my filterscript, and it is not the solution, but anyway - thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)