Page 1 of 1

Anyone for a Hex (literal)?

PostPosted: Mon Jul 07, 2008 2:06 am
by hopscc
Is there any reason cobra shouldnt have support for hex literals similarly to what i,t does for integers decimals and floats?

Purely for user and readability convenience.
The reason I ask is that I was writing some bit bashing code and I'm unhappy with my role as a hex to int preprocessor for the compiler (:-)

Re: Anyone for a Hex (literal)?

PostPosted: Mon Jul 07, 2008 9:31 pm
by Charles
Yeah, I have no opposition to a hex literal. Just never got around to it.

I wrote a long meandering response to this which I have replaced with conclusions:

hex literal: 0xA3FE
octal: 0o777
binary: 0b1101

So the prefix is a zero digit followed by the letter 'x', 'o' or 'b'. Always lower case. Give a nice error message if upper case is used.

I'd accept a patch that did all three (and included tests and IntermediateReleaseNotes.text). :-)

Re: Anyone for a Hex (literal)?

PostPosted: Mon Jul 07, 2008 10:50 pm
by hopscc
Hoped so :)
You're sorta in luck - I got a patch for hex (0x syntax ) with test file and INtRelNotes -
didnt think about octal and binary ( though off the top of my head dont think octal is worth the effort - whos got a minicomputer these days)

I'll post what I've got when I get it cleaned and finish patch testing it.
Hmm binary ....

Re: Anyone for a Hex (literal)?

PostPosted: Tue Jul 08, 2008 4:19 am
by hopscc
Heres the patch for HexLit

Re: Anyone for a Hex (literal)?

PostPosted: Tue Jul 22, 2008 4:37 am
by hopscc
Latest has binary ( and octal shudder) support and allows use of _ separators.