[Lib] NumType / NumSize

Post your working scripts, libraries and tools
HotKeyIt
Posts: 2287
Joined: 29 Sep 2013, 18:35
Contact:

[Lib] NumType / NumSize

19 May 2014, 13:12

Example wrote:

Code: Select all

MsgBox % -100 "`t" 0xFF "`t" 0xFF00FF "`t" (-99999999999) "`t" (-5.3)
  . "`n" NumType(-100) "`t" NumType(0xFF) "`t" NumType(0xFF00FF) "`t`t" NumType(-99999999999) "`t" NumType(-5.3)
  . "`n" NumSize(-100) "`t" NumSize(0xFF) "`t" NumSize(0xFF00FF) "`t`t" NumSize(-99999999999) "`t" NumSize(-5.3)
Output (AHK v2):

Code: Select all

-100	255	    16711935	-99999999999	-5.2999999999999998
Char	UChar	UInt		Int64           Double
1	    1    	4		    8               8

Code: Select all

NumType(v){
  return InStr(v,".")?"Double":v>4294967295?"UInt64":v>65535?"UInt":v>255?"UShort":v>-1?"UChar":v>-129?"Char":v>-32769?"Short":v>-2147483649?"Int":"Int64"
}

Code: Select all

NumSize(v){
  return InStr(v,".")||v>4294967295?8:v>65535?4:v>255?2:v>-129?1:v>-32769?2:v>-2147483649?4:8
}
EDIT:
Added Float/Double.
guest3456
Posts: 3180
Joined: 09 Oct 2013, 10:31

Re: [Lib] NumType / NumSize

19 May 2014, 15:04

"size" in BYTES


Return to “Scripts and Functions”

Who is online

Users browsing this forum: Black-Phoenix, TheArkive and 30 guests