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 » U++ Library support » U++ Core » U++ can't handle float to string and back for large numbers
Re: U++ can't handle float to string and back for large numbers [message #47767 is a reply to message #47766] Tue, 21 March 2017 10:52 Go to previous messageGo to previous message
cbpporter is currently offline  cbpporter
Messages: 1401
Registered: September 2007
Ultimate Contributor
Still under investigation, but:

double normalize(double d, int& exp)
{
	if(IsNull(d) || d == 0)
	{
		exp = Null;
		return d;
	}
	bool sign = (d < 0);
	if(sign) d = -d;
	exp = minmax<int>(ilog10(d), -308, +308); // 8-byte double!
	d /= ipow10(exp);
	if(d >= 10) { d /= 10; exp++; }
	if(d < 1)   { d *= 10; exp--; }
	return sign ? -d : d;
}


Looks like fixes the problem. This, and adding special case to suppress the inherent U++ IsNull mechanic. And some custom work to handle infinite better.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: new operator declared twice in MinGW TDM
Next Topic: How to bind parameter to PostCallback with Function, Event object
Goto Forum:
  


Current Time: Sun Apr 28 09:02:01 CEST 2024

Total time taken to generate the page: 0.05720 seconds