Round function?

O

ORC

Is there a round function that do a "Normal" rounding and not the round to
nearest as the Math.Rounds is?

Math.Round(3.44, 1); //Returns 3.4.
Math.Round(3.45, 1); //Returns 3.4.
Math.Round(3.46, 1); //Returns 3.5.

but what I am looking for is a round function that returns 3.5 when rounding
the value 3.45 in the above. By the way The ToString does a normal
rounding - thank you Microsoft!

Thanks
Ole
 
R

Rajagopal Pasupuleti

use
var a = Float.round(3.5);gives 4.0
var b = Float.round(3.4); gives 3.0
 
J

Jon Skeet [C# MVP]

Rajagopal Pasupuleti said:
use
var a = Float.round(3.5);gives 4.0
var b = Float.round(3.4); gives 3.0

Not sure which language you're using there, but if you mean Math.Round,
Math.Round (4.5) returns 4, so it's still using Banker's Rounding,
rather than the "normal" rounding the OP wants.
 

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

Similar Threads


Top