Rounding a Number to a String with N decimal places

D

Dr John Stockton

When rounding (or truncating) a number which may be either positive or
negative, it is sometimes necessary to round either towards plus
infinity or towards minus infinity. But those are special cases.

Normally, however, rounding should be symmetrical about zero; rounding X
should give the same digits as rounding -X, for all X.

Some of the signed routines which have been quoted here and elsewhere
are unsymmetrical.
 
G

G Roydor

Dr John Stockton a écrit:
When rounding (or truncating) a number which may be either positive or
negative, it is sometimes necessary to round either towards plus
infinity or towards minus infinity. But those are special cases.

Normally, however, rounding should be symmetrical about zero; rounding X
should give the same digits as rounding -X, for all X.

Non

2 < 2.x < 3 => 2 ou 3

-3 < -2.x < -2 => 3 ou 2

GR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top