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

Number Size Limit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thecount
Veteran Member
Join Date: Jul 2013
Old 02-04-2015 , 20:38   Number Size Limit
Reply With Quote #1

Is there a limit in sourcemod to how large a number can be? Quick question that I couldn't find on Google.
thecount is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 02-04-2015 , 20:42   Re: Number Size Limit
Reply With Quote #2

I *believe* it can't be larger than 2147483647 (MAX_INTEGER-is that defined in Sourcepawn?).
__________________
~Wliu

Last edited by Wliu; 02-04-2015 at 20:42.
Wliu is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 02-04-2015 , 21:40   Re: Number Size Limit
Reply With Quote #3

Quote:
Originally Posted by Wliu View Post
I *believe* it can't be larger than 2147483647 (MAX_INTEGER-is that defined in Sourcepawn?).
Ok thanks. Was previously using a website's ID numbers as integers instead of strings... bad idea.
thecount is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 02-05-2015 , 02:47   Re: Number Size Limit
Reply With Quote #4

In Sourcepawn, there are two data types: the cell and the String. Anything that's not declared as a String is a cell. Cells are 4 bytes (32 bits) long.

00000000 00000000 00000000 00000000

32 binary digits. Because it is a signed integer (meaning we can use negative numbers), the absolute value of the number can only be expressed by 31 of those digits. So the maximum possible number can be represented by: (2^31)-1 , or 2147483647.

https://wiki.alliedmods.net/Introduc...Pawn#Variables
__________________

Last edited by ddhoward; 02-05-2015 at 02:48.
ddhoward is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-05-2015 , 02:55   Re: Number Size Limit
Reply With Quote #5

The min for 4 bytes signed is –2147483648, btw ;p

(such as SP's cells)

https://msdn.microsoft.com/en-us/library/296az74e.aspx
__________________

Last edited by Chdata; 02-05-2015 at 02:55.
Chdata 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 01:24.


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