[Implemented] Unsigned bytes
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
[Implemented] Unsigned bytes
Restored from previous forum. Originally posted by Rings.
in range from 0-255
Getting better with a little help from my friends....thx Siggi
in range from 0-255
Getting better with a little help from my friends....thx Siggi
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Yes, i agree... as i often read on irc last time, there are many people who want and need to have a *.b from 0-255 ... I dont know any basic language where a byte can only handle -127 to +127 ... Please think ybout this...Rings wrote
in range from 0-255
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Right !!
Its not only a wish, its a *must*.
Without Bytes being Bytes, and Words
being Words, PureBasic is useless
for many things.
There are 2 differnet things, you have
to look at:
1.) Commands that use the value
Thats mostly Frederic´s choice.
When Fred thinks the command Str() should
use Signed values, its his choice.
If he also provides a command StrU() for
Unsigned values, its great.
Thats not really the important part, because
we can write our own commands too.
2.) definition and value assignment
Thats the important part, because we cannot
change the compiler !! Only Fred can do that.
Bytes are Bytes in memory, and Words are Words -
the memory cell doesnt care if its signed or unsigned.
The BIG problem:
The compiler doesnt allow:
byte.b = 255
word.w = 65535
But hey, the thing is simple -
the Compiler must allow the following values:
Fred:
__Please__ change that in the compiler.
You dont have to change 1 PureBasic command
for that, only the allowed Range in the compiler.
Result:
You can still use -127 for Bytes, when you
need it. But you can also use the value 255
and $FF for bytes, for the functions that
need unsigned values (most API functions).
BTW: it already works for LONGs, because its
allowed to write variable.l = $FFFFFFFF (thats good).
But you can also write var.l = -$FFFFFFFF (not good).
For the right allowable values see above.
Thanks,
...Danilo
(registered PureBasic user)
Edited by - Danilo on 10 March 2002 23:20:21
Right !!
Its not only a wish, its a *must*.
Without Bytes being Bytes, and Words
being Words, PureBasic is useless
for many things.
There are 2 differnet things, you have
to look at:
1.) Commands that use the value
Thats mostly Frederic´s choice.
When Fred thinks the command Str() should
use Signed values, its his choice.
If he also provides a command StrU() for
Unsigned values, its great.
Thats not really the important part, because
we can write our own commands too.
2.) definition and value assignment
Thats the important part, because we cannot
change the compiler !! Only Fred can do that.
Bytes are Bytes in memory, and Words are Words -
the memory cell doesnt care if its signed or unsigned.
The BIG problem:
The compiler doesnt allow:
byte.b = 255
word.w = 65535
But hey, the thing is simple -
the Compiler must allow the following values:
Code: Select all
Bytes = -127 -> 255 ( -$7F -> $FF )
Words = -32767 -> 65535 ( -$7FFF -> $FFFF )
DWords = -2147483647 -> 4294967295 ( -$7FFFFFFF -> $FFFFFFFF )
__Please__ change that in the compiler.
You dont have to change 1 PureBasic command
for that, only the allowed Range in the compiler.
Result:
You can still use -127 for Bytes, when you
need it. But you can also use the value 255
and $FF for bytes, for the functions that
need unsigned values (most API functions).
BTW: it already works for LONGs, because its
allowed to write variable.l = $FFFFFFFF (thats good).
But you can also write var.l = -$FFFFFFFF (not good).
For the right allowable values see above.
Thanks,
...Danilo
(registered PureBasic user)
Edited by - Danilo on 10 March 2002 23:20:21
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
THANKS Fred !!
I think you can call this unsigned support.
You can use signed and unsigned for variable
declaration.
The only special command is Str(), but thats
not a problem when we have StrU() for unsigned
numbers.
Thank you again,
...Danilo
(registered PureBasic user)
THANKS Fred !!
I think you can call this unsigned support.
You can use signed and unsigned for variable
declaration.
The only special command is Str(), but thats
not a problem when we have StrU() for unsigned
numbers.
Thank you again,
...Danilo
(registered PureBasic user)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Rings.
a.b=128
select a
case 1
PrintN("Case a = 1")
case 128
PrintN("Case a = 128")
endselect
Edited by - Rings on 12 March 2002 08:40:13
useless, if this did not work.No, as the compare will be wrong:
a.b = 255
if a > 128 ; will be a false result as internally PB use signed number
Fred - AlphaSND
a.b=128
select a
case 1
PrintN("Case a = 1")
case 128
PrintN("Case a = 128")
endselect
Edited by - Rings on 12 March 2002 08:40:13
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Mhhh... i still want to use .b up to 255 and not to when i want to check for -255 to write if bla = 128 or something like this... that would be really useless... Because i dont want to code in two different ways when checking any condition i.e.!!
Fred, please let us usw .f, .b, .w, .l like in BlitzBasic on Amiga or any other coding related language... else i think it would be better to let it as it is now...!?
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Mhhh... i still want to use .b up to 255 and not to when i want to check for -255 to write if bla = 128 or something like this... that would be really useless... Because i dont want to code in two different ways when checking any condition i.e.!!
Fred, please let us usw .f, .b, .w, .l like in BlitzBasic on Amiga or any other coding related language... else i think it would be better to let it as it is now...!?
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Hi Fred
Mhhhh.. could you not rewrite all libs and the core of the compiler to use *.b *.w and so, like in any other lanuage and as this stuff is normaly to handle?????
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Hi Fred
Mhhhh.. could you not rewrite all libs and the core of the compiler to use *.b *.w and so, like in any other lanuage and as this stuff is normaly to handle?????
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
I don't understand. On BlitzBasic Amiga (and PC) there is no unsigned support. On BlitzPC there is even no word or byte support. Only very few Basic langage support signed byte and word and I don't think it's really necessary. You want use a number above 127 ? Just use a word or a long.
Fred - AlphaSND
I don't understand. On BlitzBasic Amiga (and PC) there is no unsigned support. On BlitzPC there is even no word or byte support. Only very few Basic langage support signed byte and word and I don't think it's really necessary. You want use a number above 127 ? Just use a word or a long.
Fred - AlphaSND
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
MrVainSCL wrote:
>else i think it would be better to let it as it is now...!?
Nope !!
We really need something like:
and
for DirectX and COM-Programming (OOP), so please dont
change it back Frederic !!
cya,
...Danilo
(registered PureBasic user)
MrVainSCL wrote:
>else i think it would be better to let it as it is now...!?
Nope !!
We really need something like:
Code: Select all
GUID:
Data.l $7bf80980
Data.w $bf32, $101a
Data.b $8b, $bb, $00, $aa, $00, $30, $0c, $ab
Code: Select all
var.GUID
var\Data1 = $7bf80980
var\Data2 = $bf32
var\Data3 = $101a
change it back Frederic !!
cya,
...Danilo
(registered PureBasic user)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
I think the main idea behind .b is to use datas up to 255 in the variable and this is old as computer exist... So i dont know, why we should use .w or .l to save datas > 127 like 199... Why should be use .w to store 199 when there is a STANDARD on the computer inudstry, where a .b can be set up 255 !!?????
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
Hi FredFred wrote:
...You want use a number above 127 ? Just use a word or a long...
I think the main idea behind .b is to use datas up to 255 in the variable and this is old as computer exist... So i dont know, why we should use .w or .l to save datas > 127 like 199... Why should be use .w to store 199 when there is a STANDARD on the computer inudstry, where a .b can be set up 255 !!?????
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win98SE + Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Don.
I've come across a few situations where support for signed values would have made life much easier. I wrote a PB encryption application which used an algorithm called Blowfish. This is heavily dependent on unsigned values.
Another example is if you have a buffer of characters which you're Peek'ing through, say looking for printable characters (>ASCII 31). Any Peek'd character >127 appears as a negative value, which can mess things up unless you're careful.
PB would be more flexible if it had support for unsigned values - although I've always found ways of getting around the limitation, even if it means less elegant code. It would be nice to see this in PB one day though.
Don
I've come across a few situations where support for signed values would have made life much easier. I wrote a PB encryption application which used an algorithm called Blowfish. This is heavily dependent on unsigned values.
Another example is if you have a buffer of characters which you're Peek'ing through, say looking for printable characters (>ASCII 31). Any Peek'd character >127 appears as a negative value, which can mess things up unless you're careful.
PB would be more flexible if it had support for unsigned values - although I've always found ways of getting around the limitation, even if it means less elegant code. It would be nice to see this in PB one day though.
Don