For example, numericUpDown1 is multiplied by numericUpDown2 and the result is numericUpDown1: if 49 * 1.18 = 57.82, then if numericUpDown1 is decimalplaces = 0, the result is rounded and numericUpDown1 will be 58. . How to make it so that when decimalplaces = 0, the result is not rounded? Or so in the example 49 * 1.18 as a result in numericUpDown1 was = 57?
1 answer
numericUpDown1.Value = Math.Floor(numericUpDown1.Value * numericUpDown2.Value); Update
how to make the result also rounded up to tenths only
https://msdn.microsoft.com/en-us/library/system.math.round(v=vs.110).aspx
numericUpDown1.Value = Math.Round(numericUpDown1.Value * numericUpDown2.Value, 1); Update
It is necessary to make the Math.Floor method, not only for integers, but for tenths.
numericUpDown1.Value = Math.Floor(numericUpDown1.Value * numericUpDown2.Value * 10) / 10; - and how to make the result is also rounded up to the tenth? For example: 49 * 1.18 so that as a result tenths are rounded to 57.8? - Razi85
- incorrectly expressed. It is necessary to make the Math.Floor method, not only for integers, but for tenths. For example: it is necessary that with 49 * 1.21 = 59.29 so that the result is 59.2. (That is, so as not to round out the tenths) ( Looked through the link, did not find a suitable method) - Razi85
|
Math.Floor(numericUpDown1.Value * numericUpDown2.Value);- Igor