BUG Float x.x99999
#1

Some values, such as 25.8, are always 25.7(99999), but values like 4.8 show 4.8(00000)

Код:
new Float:amount = ConvertFloatToOneDP(floatstr(inputtext));

stock Float:ConvertFloatToOneDP(Float:value)
{
	new Float:result;
	new tempInt;
	result = value * 10;
	tempInt = floatround(result, floatround_floor);
	result = float(tempInt);
	result = result / 10;

	result += 0.0000001;
	
	return result;
}




Reply
#2

lol you don't need that function
just do

("%.1f", drugs)
Reply
#3

how to you even wrote this part, when you dont know how to format float?
Reply
#4

This is normal behaviour for float values.
It's because it's limited to 32-bits, which both holds the digits before and after the comma.
Due to being only 32-bits, the resolution is limited as well and these errors occur because of the limited resolution.

https://ryanstutorials.net/binary-tu...ting-point.php
http://cstl-csm.semo.edu/xzhang/Clas...OATING_tut.htm

These may explain a bit about it.
Reply
#5

Quote:
Originally Posted by rfr
Посмотреть сообщение
lol you don't need that function
just do

("%.1f", drugs)
I already do that dude !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)