SA-MP Forums Archive
BUG Float x.x99999 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: BUG Float x.x99999 (/showthread.php?tid=652214)



BUG Float x.x99999 - bigtigerbeee - 05.04.2018

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;
}







Re: BUG Float x.x99999 - rfr - 05.04.2018

lol you don't need that function
just do

("%.1f", drugs)


Re: BUG Float x.x99999 - CodeStyle175 - 05.04.2018

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


Re: BUG Float x.x99999 - AmigaBlizzard - 05.04.2018

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.


Re: BUG Float x.x99999 - bigtigerbeee - 06.04.2018

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

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