#MaxInteger would be fine

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2798
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

#MaxInteger would be fine

Post by Michael Vogel »

What about a nice companion for #MaxLong?

Even if #MaxInteger is the same like 1<<(#PB_Compiler_Processor<<4-1)-1 for X86 architecture it could be useful.
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: #MaxInteger would be fine

Post by eesau »

#MaxLong is a Windows api constant, not PB. That being said, equivalents in PB could be useful.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: #MaxInteger would be fine

Post by Little John »

We can easily use something like this:

Code: Select all

;-- range of *signed* 32-bit integers
#MIN_32BIT_S = -$80000000              ; = -Pow(2,31)
#MAX_32BIT_S =  $7FFFFFFF              ; =  Pow(2,31)-1

;-- range of *unsigned* 32-bit integers
#MIN_32BIT_U =  0
#MAX_32BIT_U =  $FFFFFFFF              ; =  Pow(2,32)-1

;-- range of *signed* 64-bit integers
#MIN_64BIT_S = -$8000000000000000      ; = -Pow(2,63)
#MAX_64BIT_S =  $7FFFFFFFFFFFFFFF      ; =  Pow(2,63)-1
Regards, Little John
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: #MaxInteger would be fine

Post by STARGÅTE »

Code: Select all

#PB_MinByte    = -$80
#PB_MaxByte    =  $7F
#PB_MinAscii   =  $00
#PB_MaxAscii   =  $FF

#PB_MinWord    = -$8000
#PB_MaxWord    =  $7FFF
#PB_MinUnicode =  $0000
#PB_MaxUnicode =  $FFFF

CompilerIf SizeOf(Character) = SizeOf(Ascii)
  #PB_MinCharacter = #PB_MinAscii
  #PB_MaxCharacter = #PB_MaxAscii
CompilerElse
  #PB_MinCharacter = #PB_MinUnicode
  #PB_MaxCharacter = #PB_MaxUnicode 
CompilerEndIf

#PB_MinLong = -$80000000
#PB_MaxLong =  $7FFFFFFF
#PB_MinQuad = -$8000000000000000
#PB_MaxQuad =  $7FFFFFFFFFFFFFFF

CompilerIf SizeOf(Integer) = SizeOf(Long)
  #PB_MinInteger = #PB_MinLong
  #PB_MaxInteger = #PB_MaxLong
CompilerElse
  #PB_MinInteger = #PB_MinQuad
  #PB_MaxInteger = #PB_MaxQuad 
CompilerEndIf
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Post Reply