J Jassim Rahma Jul 13, 2007 #1 I have a number, for example 0.152 or 1.729 and I want to allow to round to the first 0.010 or 0.050 or 0.100
I have a number, for example 0.152 or 1.729 and I want to allow to round to the first 0.010 or 0.050 or 0.100
M Michael A. Covington Jul 13, 2007 #2 Jassim Rahma said: I have a number, for example 0.152 or 1.729 and I want to allow to round to the first 0.010 or 0.050 or 0.100 Click to expand... One approach: Use the Decimal data type. Multiply by 100, or 20, or 10. Round to nearest integer. Divide by the number you multipied by. But also look for built-in rounding functions.
Jassim Rahma said: I have a number, for example 0.152 or 1.729 and I want to allow to round to the first 0.010 or 0.050 or 0.100 Click to expand... One approach: Use the Decimal data type. Multiply by 100, or 20, or 10. Round to nearest integer. Divide by the number you multipied by. But also look for built-in rounding functions.
J Jassim Rahma Jul 16, 2007 #3 still unable to get it.. what I want is the following: 0.171 round to 10 is 0.180 0.264 round to 10 is 0.270 0.397 round to 10 is 0.400 1.993 round to 10 is 2.000 using the same logic I want to round to 50 and 100
still unable to get it.. what I want is the following: 0.171 round to 10 is 0.180 0.264 round to 10 is 0.270 0.397 round to 10 is 0.400 1.993 round to 10 is 2.000 using the same logic I want to round to 50 and 100
B Brandon Gano Jul 16, 2007 #4 Michael's method rounds to the nearest 10th, 100th, etc. If you want to always round up, try this instead (not tested): decimal value = 0.171; value *= 10; value = decimal.Ceiling(value); value /= 10;
Michael's method rounds to the nearest 10th, 100th, etc. If you want to always round up, try this instead (not tested): decimal value = 0.171; value *= 10; value = decimal.Ceiling(value); value /= 10;
B Brandon Gano Jul 16, 2007 #5 Michael's method rounds to the nearest 10th, 100th, etc. If you want to always round up, try this instead (not tested): decimal value = 0.171; value *= 10; value = decimal.Ceiling(value); value /= 10;
Michael's method rounds to the nearest 10th, 100th, etc. If you want to always round up, try this instead (not tested): decimal value = 0.171; value *= 10; value = decimal.Ceiling(value); value /= 10;