I'm trying to round a number to the hundreds place. Yes, that's hundreds and not hundred-ths place. My example below, shows exactly what I'm talking about.
myNumber = 213.4444444
(1) Math.Round(myNumber, 2) = 213.44 <-- hundred-ths
(2) Math.Round(myNumber, 1) = 213.4 <--ten-ths
(3) Math.Round(myNumber, 0) = 213
(4) Math.Round(myNumber, -1) = 210 <--tens
(5) Math.Round(myNumber, -2) = 200 <--hundreds
Ultimately, I'm trying to arrive at (5), as I am writing a position sizing algorithm that I want to always result in an even multiple of 100 shares.
Is there a function that will round to the "left" of the decimal? I know in VB that the code woud be Round(myNumber, -2). However, in C# the Round() function does not take negative numbers.
Help.
Comment