Top "Rounding" questions

Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation.

Rounding to an arbitrary number of significant digits

How can you round any number (not just integers > 0) to N significant digits? For example, if I want to …

algorithm rounding significant-digits
GNU Octave, round a number to units precision

In GNU Octave version 3.4.3 I want to round a matrix to 2 units precision on the contents of a matrix like …

linux matrix rounding precision octave
Keeping trailing zeros

I would like to keep trailing zeros, for example, if I type: round(5.2, 3) I would like the output to be: 5.200

r math rounding
C++ significant figures

How can I do math involving significant figures in C++? I want this to work correct with measured data from …

c++ math rounding significant-digits
Round up BigDecimal to Integer value

I have a BigDecimal which value is 450.90, I want to round up to next hole integer value, and then print …

java math rounding bigdecimal
Rounding to 2 decimal places using MongoDB aggregation framework

I am using the mongodb aggregation framework and doing some calculations as shown below db.RptAgg.aggregate( { $group : { _id : {Region:"$…

mongodb aggregation-framework rounding
Rounding to nearest fraction (half, quarter, etc.)

So, I need to create the following functions but my head can't think of any possibility in PHP without complicated …

php rounding printf floor ceil
Set back default floating point print precision in C++

I want to control the precision for a double during a comparison, and then come back to default precision, with …

c++ floating-point default precision rounding
Is there any Java function or util class which does rounding this way: func(3/2) = 2?

Is there any Java function or util class which does rounding this way: func(3/2) = 2 Math.ceil() doesn't help, which by …

java rounding ceil
Round up from .5

Yes I know why we always round to the nearest even number if we are in the exact middle (i.…

r rounding r-faq