www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - float literals

reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
 From the grammar,

FloatLiteral:
	Float
	Float Suffix
	Integer ImaginarySuffix
	Integer FloatSuffix ImaginarySuffix
	Integer RealSuffix ImaginarySuffix

it appears that dmd should be able to compile something like

ifloat f1 = 0b1001i; //doesn't like this
ifloat f2 = 010i; //doesn't treat this as octal
ifloat f3 = 0xFFFFi; //doesn't like this

if built in complex numbers are going away, this will become a non issue.

real r1 = 0b1001L; //does work!
real r2 = 010L; //does work!
real r3 = 0xFFFFL; //does work!

Yay!

float f4 = 0b1001F; //doesn't like this
float f5 = 010F; //doesn't like this
float f6 = 0xFFFFF; //umm....

Obviously, the F suffix introduces an ambiguity for hex. Not sure if the 
  others should be considered a problem.

What's the deal?
Is the grammar lying to me?
Is DMD not following spec?
Am I going crazy? (well, that's a given)

At the moment, I appear to be using dmd 1.033
Dec 27 2008
parent reply BCS <ao pathlink.com> writes:
Reply to Ellery,

 From the grammar,
 
 FloatLiteral:
 Float
 Float Suffix
 Integer ImaginarySuffix
 Integer FloatSuffix ImaginarySuffix
 Integer RealSuffix ImaginarySuffix
I don't think "Integer" is referring to "IntegerLiteral". In fact, I think it is undefined.
Dec 27 2008
parent reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
BCS wrote:
 Reply to Ellery,
 
 From the grammar,

 FloatLiteral:
 Float
 Float Suffix
 Integer ImaginarySuffix
 Integer FloatSuffix ImaginarySuffix
 Integer RealSuffix ImaginarySuffix
I don't think "Integer" is referring to "IntegerLiteral". In fact, I think it is undefined.
Umm.. Ok. I guess I'll just omit it from my grammar until it is defined... At least for RealSuffix it appeared very much to be referring to IntegerLiteral
Dec 28 2008
next sibling parent BCS <ao pathlink.com> writes:
Reply to Ellery,

 BCS wrote:
 
 Reply to Ellery,
 
 From the grammar,
 
 FloatLiteral:
 Float
 Float Suffix
 Integer ImaginarySuffix
 Integer FloatSuffix ImaginarySuffix
 Integer RealSuffix ImaginarySuffix
I don't think "Integer" is referring to "IntegerLiteral". In fact, I think it is undefined.
Umm.. Ok. I guess I'll just omit it from my grammar until it is defined... At least for RealSuffix it appeared very much to be referring to IntegerLiteral
As that is in lex.html I don't think it is part of the syntax but part of the lexical stuff. OTOH I seem to recall that there are some issues with FP literals vs slices ".."
Dec 29 2008
prev sibling parent BCS <ao pathlink.com> writes:
Reply to Ellery,

 BCS wrote:
 
 Reply to Ellery,
 
 From the grammar,
 
 FloatLiteral:
 Float
 Float Suffix
 Integer ImaginarySuffix
 Integer FloatSuffix ImaginarySuffix
 Integer RealSuffix ImaginarySuffix
I don't think "Integer" is referring to "IntegerLiteral". In fact, I think it is undefined.
Umm.. Ok. I guess I'll just omit it from my grammar until it is defined... At least for RealSuffix it appeared very much to be referring to IntegerLiteral
As that is in lex.html I don't think it is part of the syntax but part of the lexical stuff. OTOH I seem to recall that there are some issues with FP literals vs slices ".."
Dec 29 2008