Forums

Anyone for a Hex (literal)?

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Anyone for a Hex (literal)?

Postby hopscc » Mon Jul 07, 2008 2:06 am

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 (:-)
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Anyone for a Hex (literal)?

Postby Charles » Mon Jul 07, 2008 9:31 pm

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). :-)
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Anyone for a Hex (literal)?

Postby hopscc » Mon Jul 07, 2008 10:50 pm

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 ....
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Anyone for a Hex (literal)?

Postby hopscc » Tue Jul 08, 2008 4:19 am

Heres the patch for HexLit
Attachments
HexLit.patch
(6.11 KiB) Downloaded 633 times
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand

Re: Anyone for a Hex (literal)?

Postby hopscc » Tue Jul 22, 2008 4:37 am

Latest has binary ( and octal shudder) support and allows use of _ separators.
hopscc
 
Posts: 632
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 100 guests

cron