IonicWind Software

IWBasic => General Questions => Topic started by: bart75028 on March 05, 2008, 05:15:59 PM

Title: Using VAL with a hexadecimal string literal.
Post by: bart75028 on March 05, 2008, 05:15:59 PM
Can anyone tell me why  PRINT VAL("0x30")  prints "0", rather than the expected "48"? And where I could have found that in the Users Guide?

I'm sad because I feel stoopid.

OPENCONSOLE
DEF n AS INT
n = VAL("0x30")
PRINT n                                        :' display "0"    Why not "48"?
n = VAL("48")
PRINT n                                        :' display "48"   
DO: UNTIL INKEY$ <> ""
CLOSECONSOLE
END
Title: Re: Using VAL with a hexadecimal string literal.
Post by: Ionic Wind Support Team on March 05, 2008, 05:36:31 PM
VAL only works with decimal numbers, not hex, not octal, not binary either ;)

You can use the C library function sscanf for converting hex numbers.

Quote
And where I could have found that in the Users Guide?

And you expect I am supposed to imagine every possible combination a user could enter?  Never said I was perfect, and since I wrote the users guide without help there are bound to be some oversights.  It has been pointed out to me that things that to me are common sense, might not be so for others  ;D

Paul.

Title: Re: Using VAL with a hexadecimal string literal.
Post by: bart75028 on March 05, 2008, 06:09:06 PM
I just assumed I was doing it rong. Thanks for the info.
Title: Re: Using VAL with a hexadecimal string literal.
Post by: LarryMc on March 05, 2008, 06:47:24 PM
Quote from: Paul Turley on March 05, 2008, 05:36:31 PM
things that to me are common sense, might not be so for others
Talking about me again, heh? ;)

Larry