Extract 10 digits after decimal point and apply rounding up to 3 postions?

Should do the trick for positive numbers. Test if you get the desired behavior for negative numbers (not given in your examples). If not, use Floor instead of Ceiling for negatives.

Up vote 1 down vote favorite share g+ share fb share tw.

I want to implement logic of rounding up to 3 decimal positions after rounding. If the value of decimal place 1 – 3 is equal to 000 (regardless of the whole number), and the value of the 4th thru the 10th decimal place is greater than 0, the 3rd decimal place in the display will round up. Example: 1.1230000000 --> 1.123 1.1230010000 --> 1.123 1.1230600000 --> 1.124 1.0000010000 --> 1.001 1.0003000000 --> 1.003 5.0000001234 --> 5.001 looking forward c# sharepoint decimal rounding link|improve this question edited Nov 23 '10 at 22:02p.

Campbell28.8k858125 asked Nov 23 '10 at 21:43Kris112.

1 First, that's a pretty weird "rounding" routine. Second, your example seems to be wrong or I don't understand it. Based on your description you should get 1.124 from 1.1230010000, not 1.123 as in your example.

– TToni Nov 23 '10 at 21:56 TToni, you are right...i don't know how I made that mistake. We need to do this jsut for display purpose as we cannot display long numbers. – Kris Nov 23 '10 at 22:02 So can you think of any logic for this?

I know its weird but I hv to do it as requirement...! – Kris Nov 23 '10 at 22:02 What data type are you using - float, double, or decimal? Depending on the type, a routine that depends on small differences in decimal values would be impossibly flaky due to problems representing decimal fractions in binary. – Ben Nov 23 '10 at 22:04 1.00030000 to 1.003?

Or 1.001? – TToni Nov 23 '10 at 22:05.

Math. Ceiling(myNumber*1000)/1000; should do the trick for positive numbers. Test if you get the desired behavior for negative numbers (not given in your examples).

If not, use Floor instead of Ceiling for negatives.

Thanks TToni. This is perfectly working. Simply superb!

– Kris Nov 29 '10 at 16:53 Glad to help out, Kris. – TToni Nov 29 '10 at 16:55 hey TToni, Want to ask one more thing. While I am dividing a double number by another double number, how can I retain the same amount of decimal places after division?

– Kris Nov 29 '10 at 17:27 I am sorry. My question is that I want to keep the number after division with exactly 10 decimal places after decimal point. – Kris Nov 29 '10 at 17:29 Is Math.

Round(a/b,10) what you are looking for? – TToni 10 dec8 at 20:08.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions