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++ Library : Other (not classified elsewhere) » rounding to decimals implementation
rounding to decimals implementation [message #44429] Wed, 11 March 2015 11:24 Go to next message
aftershock is currently offline  aftershock
Messages: 143
Registered: May 2008
Experienced Member

Hi all,

I have not found that in the library.

Here is the implementation.

double roundd ( double n, int decimals )
{
double p = ipow10 ( decimals );
return floor ( n*p + 0.5 ) / p;
}

A.
Re: rounding to decimals implementation [message #44430 is a reply to message #44429] Wed, 11 March 2015 11:43 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

aftershock wrote on Wed, 11 March 2015 11:24
I have not found that in the library.

Here is the implementation.

double roundd ( double n, int decimals )
{
double p = ipow10 ( decimals );
return floor ( n*p + 0.5 ) / p;
}


Hi Aftershock,

It is not in the library, but you exactly reinvented what is written in documentation Very Happy See About rounding double values.

Best regards,
Honza
Previous Topic: Image DnD into Upp app
Next Topic: Bug? Directoryexists does not recognise directory if...
Goto Forum:
  


Current Time: Fri Apr 19 03:11:48 CEST 2024

Total time taken to generate the page: 0.08613 seconds