Bug 7 : allow doubles in the preprocessor
Last modified: 2010-03-17 13:25




Status:
RESOLVED
Resolution:
FIXED -
Priority:
P4
Severity:
enhancement

 

Reporter:
fry
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2005-05-12 18:44
for casting, etc.. particularly for Math.cos() et al
Additional Comment #1 From fjen 2007-02-25 07:24
PdeEmitter.java (Line 883)

-----------------------------

case NUM_DOUBLE:
if (Preferences.getBoolean("preproc.substitute_floats")) { //, true) ) {
out.print(ast.getText().replaceAll("d", ""));
out.print("f");
}
else
{
out.print(ast.getText());
}

-----------------------------

fixes the "100d" / "100.0D" issue, but will break:

float f = 2147483647.0f;
double d = 21474836470001.0d;

println( f );
println( d );

// preproc.substitute_floats=true
//2.14748365E9
//2.147483648E13

// preproc.substitute_floats=false
//2.14748365E9
//2.1474836470001E13

F
Additional Comment #2 From fjen 2007-02-25 07:29
oh, the replacement should probably be:

out.print(ast.getText().toLowerCase().replaceAll("d", ""));

or

out.print(ast.getText().replaceAll("d|D", ""));

F
Additional Comment #3 From fry 2007-02-25 14:16
hm, ok.. thanks for looking into it. this will require some testing.
Additional Comment #4 From fjen 2007-02-26 23:49
yeah, the fix resolves the problem (in up to 124) of "1000.0d" getting a f appended
"1000.0df", leaving the resulting java code uncompileable.

maybe you have a better idea on how to do it ...

F
Additional Comment #5 From MrFeinberg 2010-03-15 20:13
I interpreted this to mean that the literal "d" on a numeric literal should
*always* be respected, even when substitute_floats is true. I have
implemented the fix this way. Please reopen if I misunderstood.

Fixed; please verify and close.