October 29, 2025, 10:19:36 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Using VAL with a hexadecimal string literal.

Started by bart75028, March 05, 2008, 05:15:59 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bart75028

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

Ionic Wind Support Team

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.

Ionic Wind Support Team

bart75028

I just assumed I was doing it rong. Thanks for the info.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library