いつも色々教えていただきありがとうございます。
数値を切り上げする為の方法を確認しています。
142→150
321→330
のように小数点1ケタを切り上げる方法を
教えてください。
よろしくお願いします。
いつも色々教えていただきありがとうございます。
数値を切り上げする為の方法を確認しています。
142→150
321→330
のように小数点1ケタを切り上げる方法を
教えてください。
よろしくお願いします。
You can do it with a simple mathematical expressions.
in this case 142%10 = 2 ( intRemainder = 2 )
Process the below two steps only if intReminder <> 0
intAddValue = 10 - intRemainder (result is 8)
Add intAddValue to the original number.
142 + intAddValue (result 150)
Similarly for 321
Step1: intReminder = 321%10 = 1
Step2: intAddValue = 10-1 = 9
Step3: 321+9 = 330
Regards,
Karthik Byggari
代入右辺に、math.ceiling(数値)ってのがあります…
こんにちは
Math.Ceilingや剰余を使うのが王道かと思いますが、型変換の特性を考慮した以下でも可能です。xが整数型の変数として
CInt(x / (-10)) * (-10)
#コンパクトですが可読性が少々良くないかも。