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

If you have feature requests, this is the place to post them. Please note your idea may already be something we have already discussed and decided against, or something we are working on privately, and we cannot be held responsible for any similarities in such instance. Whilst we cannot respond to every suggestion, your idea will be read and responded to where possible. Thank you for your input!
Post Reply
mobluse
Posts: 175
Joined: Tue Aug 04, 2020 2:16 pm
Location: Lund, Sweden
Contact:

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

Post by mobluse »


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

X16&C64 Quiz: Try It Now! Huge Char Demo: Try It Now! DECPS: Try It Now! Aritm: Try It Now!
Post Reply