Page 1 of 1
Unsigned bytes, words, longs and quads
Posted: Wed Dec 10, 2008 2:26 pm
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!
Posted: Wed Dec 10, 2008 5:53 pm
by Trond
.c behaves like an unsigned type, but it's only for byte/word.
Posted: Wed Dec 10, 2008 5:54 pm
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.
Posted: Wed Dec 10, 2008 7:19 pm
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.
Posted: Tue Dec 16, 2008 12:47 am
by Seymour Clufley
+1
Posted: Mon Apr 13, 2009 12:55 am
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
Posted: Mon Apr 13, 2009 8:21 am
by Michael Vogel
Great ideas, I'd also like to be able to handle byte values without additional ANDs and ORs...
...AND (OR

) some type casting functions, like BYTE{} would be fine!
Michael
Posted: Wed Apr 15, 2009 6:13 pm
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.
Posted: Thu Apr 16, 2009 1:03 am
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
Posted: Thu Apr 16, 2009 8:05 am
by THCM
It's of course not the big "marketing feature". It's a very basic feature, but nonetheless a very important one.
Posted: Thu Apr 16, 2009 8:16 am
by DarkDragon
Yes it is important.
Posted: Thu Apr 16, 2009 12:37 pm
by pdwyer
I think people notice it's absence before they purchase though, but I doubt many change their purchasing decision because of it