Raised This Month: $32 Target: $400
 8% 

Str to float


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-19-2018 , 09:22   Str to float
Reply With Quote #1

Whats the different between those two natives

str_to_float & floatstr

for some reason str_to_float gives false outputs.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-19-2018 at 16:58.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-19-2018 , 10:32   Re: Str to float
Reply With Quote #2

Where did you even find strfloat?

Quote:
Originally Posted by Natsheh View Post
for some reason str_to_float gives false outputs.
That function has been there since the beginning, if it gave wrong results it would've been reported and fixed long ago. You should provide your code and the data you test it on.
__________________
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-19-2018 , 16:59   Re: Str to float
Reply With Quote #3

Quote:
Originally Posted by KliPPy View Post
Where did you even find strfloat?


That function has been there since the beginning, if it gave wrong results it would've been reported and fixed long ago. You should provide your code and the data you test it on.

Sorry i meant floatstr, here is the code.


Try changing floatstr to str_to_float.
Attached Files
File Type: sma Get Plugin or Get Source (jb_days_spawns.sma - 614 views - 18.6 KB)
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 03-19-2018 at 17:02.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-19-2018 , 17:15   Re: Str to float
Reply With Quote #4

If you want to prove that a native isn't working properly then create a smallest possible script that proves it. I'm not going to run that, especially because it depends on other plugins which I'd have to search for.
These two natives are nearly equal, but everyone pretty much uses str_to_float - it has a more descriptive name.
__________________

Last edited by klippy; 03-19-2018 at 17:16.
klippy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 03-19-2018 , 17:40   Re: Str to float
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
If you want to prove that a native isn't working properly then create a smallest possible script that proves it. I'm not going to run that, especially because it depends on other plugins which I'd have to search for.
These two natives are nearly equal, but everyone pretty much uses str_to_float - it has a more descriptive name.
Is there any differences between them? If there is can you list them.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-19-2018 , 17:50   Re: Str to float
Reply With Quote #6

floatstr uses atof from the C standard library, while str_to_float has its own implementaton. atof can accept more input, but is also subject to change. For example in C++11 it had more functionality added (acceps hexadecimal, infinity and NaN values). It seems that floatstr is a relic from AMX days or even earlier as it uses old ways of retrieving strings from Pawn.
In general, for ordinary float values there is absolutely no difference.
atof information: http://www.cplusplus.com/reference/cstdlib/atof/
str_to_float implementation: https://github.com/alliedmodders/amx...tring.cpp#L482
__________________

Last edited by klippy; 03-19-2018 at 17:57.
klippy is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:14.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode