Restored from previous forum. Originally posted by GPI.
for example val("$1234") and val("%01001011").
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
[Implemented] Extension for VAL()
-
- 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 Amiga5k.
You could use Hex() or Bin() within the Val() statement to achieve this, I think.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
You could use Hex() or Bin() within the Val() statement to achieve this, I think.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
I think the MathExtras user library has the commands IBin and IHex which does what GPI is looking for.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
Nope, because the strings they create are in hexadecimal which brings you to the same point that GPI is at...how to convert a string in a non-decimal number base to a number.Originally posted by Amiga5k
You could use Hex() or Bin() within the Val() statement to achieve this, I think.
I think the MathExtras user library has the commands IBin and IHex which does what GPI is looking for.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Amiga5k.
I'm thinking that GPI wants to accept a string from a user or manipulate a string suring runtime and get it's 'real' value? If not, wouldn't Val($1234) or Val(%01001011) work? (without the quotes). Haven't tried this, though.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
I'm thinking that GPI wants to accept a string from a user or manipulate a string suring runtime and get it's 'real' value? If not, wouldn't Val($1234) or Val(%01001011) work? (without the quotes). Haven't tried this, though.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
1) Val does not convert number bases other than decimal
2) Without the quotes you are passing the wrong type of parameter to Val - it has to be a string.
3) If you had $1234 in a numeric variable then you would not need to convert it with Val. A number is the same number no matter what base it is displayed in for our understanding.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
Yes, that seems to be the case.Originally posted by Amiga5k
I'm thinking that GPI wants to accept a string from a user or manipulate a string suring runtime and get it's 'real' value?
No, because:If not, wouldn't Val($1234) or Val(%01001011) work? (without the quotes).
1) Val does not convert number bases other than decimal
2) Without the quotes you are passing the wrong type of parameter to Val - it has to be a string.
3) If you had $1234 in a numeric variable then you would not need to convert it with Val. A number is the same number no matter what base it is displayed in for our understanding.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm