Raised This Month: $51 Target: $400
 12% 

Solved float(int) bug ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-23-2022 , 20:39   float(int) bug ?
Reply With Quote #1

hello, i have this code

PHP Code:
            new iSysTime get_systime();
            new 
Float:fTime float(iSysTime);

            new 
Float:fSubTime floatsub(g_fOpenDelay[id], fTime)
            new 
iCmp floatcmp(OPEN_DELAYfSubTime);
            
            
client_print(idprint_chat"ftime: %f(%i) fsubtime: %f floatcmp: %i opendelay: %f"fTimeiSysTime,fSubTimeiCmpg_fOpenDelay[id]) 
but the ftime output is so wrong even if iSysTime is the right one.

Output:
Code:
ftime: 1653352704.000000(1653352657) fsubtime: 0.000000 floatcmp: 1 opendelay: 1653352704.000000
ftime: 1653352704.000000(1653352661) fsubtime: 0.000000 floatcmp: 1 opendelay: 1653352704.000000
ftime: 1653352704.000000(1653352662) fsubtime: 0.000000 floatcmp: 1 opendelay: 1653352704.000000
ftime: 1653352704.000000(1653352664) fsubtime: 0.000000 floatcmp: 1 opendelay: 1653352704.000000
ftime: 1653352704.000000(1653352665) fsubtime: 0.000000 floatcmp: 1 opendelay: 1653352704.000000
maybe it s not working with big int values ?

Last edited by lexzor; 05-24-2022 at 10:32.
lexzor is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 05-24-2022 , 00:41   Re: float(int) bug ?
Reply With Quote #2

new Float:a = float(get_systime)
__________________
bigdaddy424 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-24-2022 , 08:45   Re: float(int) bug ?
Reply With Quote #3

tried, don t work
lexzor is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-24-2022 , 09:28   Re: float(int) bug ?
Reply With Quote #4

Quote:
Originally Posted by lexzor View Post
tried, don t work
Why using float with int? use a custom format or format_time
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-24-2022 , 09:39   Re: float(int) bug ?
Reply With Quote #5

Its because systime is a big number and max variable size is limited to 32bit and when floating it, the value get shifted and you might end up with invalid results.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 05-24-2022 at 09:43.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lexzor
Veteran Member
Join Date: Nov 2020
Old 05-24-2022 , 10:32   Re: float(int) bug ?
Reply With Quote #6

got it, i will use format_time

Thanks
lexzor is offline
Reply



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 10:24.


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