457,695 Members | 1,196 Online Need help? Post your question and get tips & solutions from a community of 457,695 IT Pros & Developers. It's quick & easy.

# Take care of decimal gaps

 P: n/a Hi all, I have a collection (an array for example) of decimal values. I need to round them and take care of the roundings. For example, if I have decimal a = 10.50m should became 10 and if decimal b = 10.51m should became 11. Then I need to populate a decimal variable with these rest with the sing values. So 0.50 it will have the "+" sign, and the 0.49 will have "-" sign. In this example decimal c = + 0.50 - 0.49 // It will be 0.01 How can I accomplish this? Thanks in advance. -- Luigi Jun 27 '08 #1
5 Replies

 P: n/a On Jun 18, 11:16*am, Luigi

 P: n/a "Jon Skeet [C# MVP]" wrote: On Jun 18, 11:16 am, Luigi

 P: n/a On Jun 18, 11:57*am, Luigi

 P: n/a Luigi has brought this to us : Hi all, I have a collection (an array for example) of decimal values. I need to round them and take care of the roundings. For example, if I have decimal a = 10.50m should became 10 and if decimal b = 10.51m should became 11. Then I need to populate a decimal variable with these rest with the sing values. So 0.50 it will have the "+" sign, and the 0.49 will have "-" sign. In this example decimal c = + 0.50 - 0.49 // It will be 0.01 How can I accomplish this? Thanks in advance. I'm guessing that you want to round a monetary value to whole (say) euro's and keep the "rounding offset"? What about: decimal originalAmount = 10.50m; decimal wholeEuros = Math.Round(originalAmount); decimal centsFraction = originalAmount - wholeEuros; Hans Kesting Jun 27 '08 #5

 P: n/a Luigi wrote: Hi all, I have a collection (an array for example) of decimal values. I need to round them and take care of the roundings. For example, if I have decimal a = 10.50m should became 10 and if decimal b = 10.51m should became 11. Then I need to populate a decimal variable with these rest with the sing values. So 0.50 it will have the "+" sign, and the 0.49 will have "-" sign. In this example decimal c = + 0.50 - 0.49 // It will be 0.01 How can I accomplish this? IEnumerable Thanks in advance. Jun 27 '08 #6

### This discussion thread is closed

Replies have been disabled for this discussion. 