Hi and loword

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Hi and loword

Post by jacdelad »

Searched for this and got here. Works so far, but if you want to use a formula as input variable, it doesn't work. Simple workaround:

Code: Select all

Macro LOWORD(a):((a)&$ffff):EndMacro
Macro HIWORD(a):(((a)>>16)&$ffff):EndMacro
Macro MAKELONG(a,b):(((a)&$ffff)+(b)<<16):EndMacro
Last edited by jacdelad on Fri Dec 15, 2023 10:11 pm, edited 1 time in total.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
HeX0R
Addict
Addict
Posts: 1189
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Hi and loword

Post by HeX0R »

You've copied the mistake from Rescator :mrgreen:
User avatar
jacdelad
Addict
Addict
Posts: 1993
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: Hi and loword

Post by jacdelad »

Which mistake? :shock: The missing "&"? Corrected it. Thanks for pointing that out (if there's no more mistakes in it).
ANyway, I agree with everyone that these should be built-in.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Quin
Addict
Addict
Posts: 1131
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: Hi and loword

Post by Quin »

+1
User avatar
idle
Always Here
Always Here
Posts: 5840
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Hi and loword

Post by idle »

This can be easily done in a structure

Code: Select all

Structure int32 
  StructureUnion
    a.a[4]
    u.u[2]
    l.l
  EndStructureUnion
EndStructure  

Global a.int32 
a\l = $aaaabbbb 

Debug Hex(a\u[0]) 
Debug Hex(a\u[1]) 
Post Reply