Home » Extra libraries, Code snippets, applications etc. » U++ Esc Interpreter, Esc Macros and templates » To advance using int64 in ESC (Two Bugfixes and progression of parsing to inspire)
|To advance using int64 in ESC [message #43678]
||Fri, 19 September 2014 20:24
Registered: March 2006
as recently the internal representation of number was optimized for int64,
I have taken the ball and added optimized parsing and done a bit more of internal optimization.
First the bugfixes in EscValue::ToString() function.
If the number has the value of INT64_MIN it is not printed because FormatInt64() treats as Null. But it should, as number has other value for Null.
if((int64)number == number)
s << FormatInt64((int64)number);
int64 in= (int64)number;
if(in == number)
s << String(in < 0 ? "-" + Format64(-in) : Format64(in));
s << FormatInt64(i64);
s << String(i64 < 0 ? "-" + Format64(-i64) : Format64(i64));
Now my changes.
The optimized parser will first detect if it is a double (length and . or exponent) and if not to parse the string with the uint64 parser.
This works also if it really is a double (ie. string length == 18 but outside int64 range). Caveat is it will get slightly different double values than with the double parser.
The EscValue::IsInt() / EscValue::GetInt sequences are replaced with one function, named GetIntOnly.
If some dev will take my changes as inspiration to get them into U++ it would be great.
I have attached the zip file of my sources.
When diffing please ignore String/WString differences.
If you have questions about my code please ask.
(Size: 17.50KB, Downloaded 126 times)
Current Time: Fri Aug 18 18:26:20 CEST 2017
Total time taken to generate the page: 0.00737 seconds