LibUnsigned: unsigned ops for 32-bit dword & 64-bit quad

Share your advanced PureBasic knowledge/code with the community.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: LibUnsigned: unsigned ops for 32-bit dword & 64-bit quad

Post by wilbert »

Keya wrote:now in "SUPERMODULAR" form!!!
Nice work Keya 8)
Keya wrote:All tests looked good on my Win/Linux/OSX x86 + x64 systems, please run TestAll32.pb and TestAll64.pb and you should see "All tests passed" at the bottom of Debug window output.
Works fine :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: LibUnsigned: unsigned ops for 32-bit dword & 64-bit quad

Post by Keya »

now that PB has a C backend I would love it if this library could be made redundant by a native unsigned 32bit/64bit datatype :)
User avatar
idle
Always Here
Always Here
Posts: 5902
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: LibUnsigned: unsigned ops for 32-bit dword & 64-bit quad

Post by idle »

I suspect it can be done now in the c backend but I can't figure out how to get it to work with procedures :cry:

Code: Select all

;pbcompilerc -d Unsigned.pb 

CompilerIf #PB_Compiler_Backend = #PB_Backend_C 
!unsigned int v_a =0;  
!unsigned int v_b =0;
CompilerEndIf 

Global a.l, b.l,c.l,d.l 

a = 4294967295 ;a is unsigned 
c = 4294967295 ;c is signed  

b = a / 2

If a > b 
  Debug "a is unsigned"
Else 
  Debug "a is signed"
EndIf   

Debug a 
Debug b 

d = c / 2 

If c > d 
  Debug "c is unsigned"
Else 
  Debug "c is signed"
EndIf   

Debug c 
Debug d  
User avatar
idle
Always Here
Always Here
Posts: 5902
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: LibUnsigned: unsigned ops for 32-bit dword & 64-bit quad

Post by idle »

Think I've got this figured out now.

https://www.purebasic.fr/english/viewtopic.php?t=78386
Post Reply