Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Hi,
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.

Change
			if((int64)number == number)
				s << FormatInt64((int64)number);
to
			int64 in= (int64)number;
			if(in == number)
				s << String(in < 0 ? "-" + Format64(-in) : Format64(in));

and below
			s << FormatInt64(i64);
to
			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[64]() / EscValue::GetInt[64] sequences are replaced with one function, named GetInt[64]Only.

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.

Thanks.
  • Attachment: toUpp.zip
    (Size: 17.50KB, Downloaded 129 times)
Previous Topic: USC file syntax and questions
Next Topic: adding to_number(hex) and find?
Goto Forum:
  


Current Time: Mon Nov 20 16:14:33 CET 2017

Total time taken to generate the page: 0.01598 seconds