diff -r 9ef7e549391f -r 8cc91ef94754 parser.cxx --- a/parser.cxx Tue Aug 14 00:59:39 2012 +0300 +++ b/parser.cxx Tue Aug 14 01:54:17 2012 +0300 @@ -848,6 +848,35 @@ b->Write (DH_PUSHSTRINGINDEX); b->Write (PushToStringTable (token.chars())); break; + case TYPE_FLOAT: { + str floatstring; + + MustNumber (true); + floatstring += token; + + // Go after the decimal point + if (!PeekNext ().compare(".")) { + MustNext ("."); + MustNumber (false); + floatstring += "."; + floatstring += token; + } + + // TODO: Casting float to word causes the decimal to be lost. + // Find a way to store the number without such loss. + float val = atof (floatstring); + b->Write (DH_PUSHNUMBER); + b->Write (static_cast ((val > 0) ? val : -val)); + if (val < 0) + b->Write (DH_UNARYMINUS); + + // TODO: Keep this check after decimal loss is fixed, but make + // it a real precision loss check. 55.5123 -> 55.512299, this + // should probably be warned of. + float check = static_cast (static_cast (val)); + if (val != check) + ParserWarning ("floating point number %f loses precision (-> %f)", val, check); + } } }