Unsigned bytes, words, longs and quads

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
mback2k
Enthusiast
Enthusiast
Posts: 257
Joined: Sun Dec 02, 2007 12:11 pm
Location: Germany

Unsigned bytes, words, longs and quads

Post by mback2k »

It would be really neat if PureBasic could include support for unsigned integer types. Especially with networking tasks (using Structures to read/write the memory) and easy value comparision it would be useful.

Example:

Code: Select all

ubyte.ub ; 1 Byte
uword.uw ; 2 Byte
ulong.ul ; 4 Byte
uquad.uq ; 8 Byte
uinteger.ui ; 4/8 Byte
Thanks in advance!
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

.c behaves like an unsigned type, but it's only for byte/word.
User avatar
mback2k
Enthusiast
Enthusiast
Posts: 257
Joined: Sun Dec 02, 2007 12:11 pm
Location: Germany

Post by mback2k »

Trond wrote:.c behaves like an unsigned type, but it's only for byte/word.
I know, and it changes it's size with Unicode enabled/disabled. It's a special length type like .s{N}, too. Thats why I would like to have additional types.
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

It's not the first time this was requested and I think this is still a very important feature request. I'm writing all my C64 tools like packers and converters with Purebasic and it would be a lot easier having unsigned integer types.
The Human Code Machine / Masters' Design Group
Seymour Clufley
Addict
Addict
Posts: 1264
Joined: Wed Feb 28, 2007 9:13 am
Location: London

Post by Seymour Clufley »

+1
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

+1

For me, the main reason is stepping through byte values in a memory block. A few times with encryption, compression and sorting algorithms etc you use the byte value as a an array index for fast lookups.

If the byte value is over 127 then the number goes negative causing an array out of bounds. The whole purpose of these is speed so the &ff methods and not only ugly but I would guess slower in long tight loops.

.c is effectively useless for this purpose unless you want to ban yourself from using unicode (while is what I've done for the moment)

I read a lot of other posts and heard that there were casting issues etc for comparisons.... Other languages seem to do this fine though. (I'm not saying it's easy, just possible) Powerbasic had no problem with it.

Please consider
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post by Michael Vogel »

Great ideas, I'd also like to be able to handle byte values without additional ANDs and ORs...
...AND (OR :wink:) some type casting functions, like BYTE{} would be fine!

Michael
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

THCM wrote:It's not the first time this was requested and I think this is still a very important feature request. I'm writing all my C64 tools like packers and converters with Purebasic and it would be a lot easier having unsigned integer types.
[+1]
I do similar, but not only for C64, but for many other retro Computers, mainly ZX Spectrum.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I suspect that since this has been requested so long ago that there is some issue here making it difficult to implement...

Perhaps if PB are looking for a topic of their next blog article they might consider going through it for us :)

Worth a try
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

It's of course not the big "marketing feature". It's a very basic feature, but nonetheless a very important one.
The Human Code Machine / Masters' Design Group
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Yes it is important.
bye,
Daniel
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post by pdwyer »

I think people notice it's absence before they purchase though, but I doubt many change their purchasing decision because of it
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
Post Reply