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

Solved int64/BigInt issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 08-04-2023 , 17:23   int64/BigInt issue
Reply With Quote #1

I have came across a addition problem with two integers being too big for int32. Anyone good with math?

iCreated is a Unix Timestamp (1691179456)
iTime is defined as 6 months in seconds (15778463).
Code:
new iCreated = SQL_ReadResult( hQuery, 1 ); new iTime = SQL_ReadResult(hQuery, 2) * 60; //sec to min if( (iCreated + iTime) > get_systime() ) // too big to pass through here { ... }

Last edited by Rirre; 08-05-2023 at 06:03. Reason: Solved by not using min to sec
Rirre is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 08-04-2023 , 17:41   Re: int64/BigInt issue
Reply With Quote #2

get_systime - icreated > itime


anyways you should be able to use ghem
lexzor is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-04-2023 , 23:53   Re: int64/BigInt issue
Reply With Quote #3

In AMX Mod X, normal variables are signed 32-bit integers. This means they have a range from -2,147,483,648 to 2,147,483,647. In the context of timestamps, the usable part of this range is from 0 to 2,147,483,647. This translates to "Tue Jan 19 03:14:07 2038 UTC". So, any math that occurs that generates a timestamp that represents a date before the year 2038 will work just fine and can't be "too big". Your example is a time stamp for "Sat Feb 03 10:589 2024 UTC" and will not be an issue.

P.S. Your comment "sec to min" is wrong, that conversion is actually doing "min to sec".
__________________
fysiks is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 08-05-2023 , 04:31   Re: int64/BigInt issue
Reply With Quote #4

Quote:
Originally Posted by lexzor View Post
get_systime - icreated > itime
It will always fail no matter what values iCreated and/or iTime has.

Quote:
Originally Posted by fysiks View Post
...P.S. Your comment "sec to min" is wrong, that conversion is actually doing "min to sec".
Ah :facepalm: That was the problem. Thank you!

Last edited by Rirre; 08-05-2023 at 16:08.
Rirre 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 13:06.


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