Jump to content
  • 0
mobluse

VAL() should work for hex, & HEX$(), for negative

Question

Posted (edited)

I think VAL() should work for hexadecimal numbers and not only for decimal as it does now.

PRINT VAL("$FFFFFFF")
should print: 268435455.

I believe it would not be too difficult to implement since the code already exists for converting numbers in code.

PRINT $FFFFFFF
works now, and types: 268435455.

Especially now when HEX$() exists in the next prerelease (-39). HEX$() converts without $ as prefix, but I think that's OK since $ could be added easily if one wants. It's also similar to how it works in other BASICs, e.g. GW-BASIC: http://www.antonis.de/qbebooks/gwbasman/hexs.html

In GW-BASIC HEX$() also works for negative numbers, e.g. HEX$(-32768) is "8000", but negative numbers doesn't currently work with X16 BASIC HEX$().

I don't think it's necessary to implement VAL() for binary numbers, even though BIN$() exists, but if one did they should probably have % as prefix, e.g. %101.

FreePascal uses the same prefixes:
https://www.freepascal.org/docs-html/ref/refse6.html

Edited by mobluse

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use