Round up to three decimals

Jacobsen

New Member
I'm trying to round up to three decimals without any luck.
Please see codes below.

<code><pre><font size=2 face='Courier'>
SYMBOL BattNomFloatVoltage = 1362
SYMBOL SenseAmp = w2 ;b4:b5
SYMBOL RestOprund = B10

DisplayLine3:
SenseAmp= 93 ;= 4.50 Amp
Byte = $94; Start Line 3
GOSUB SendCmdByte
EEPROM 26,(&quot;Ladning: &quot;) ;26..35
FOR get = 26 TO 35
READ get,byte
GOSUB SendDataByte
NEXT

LET SenseAmp = SenseAmp * 50 / 32 * 100 / 32

DisplayLine4:
'Watt = w3:b8:b9
Byte = $D4; Start Line 4
GOSUB SendCmdByte
EEPROM 36,(&quot;Power: &quot;) ;51..65
FOR get = 36 TO 45
READ get,byte
GOSUB SendDataByte
NEXT

LET Watt = SenseAmp /10 * BattNomFloatVoltage /10

RestOprund = MaxFlowDisplay / Watt

Let Watt = Watt + RestOprund + 1

SERTXD(&quot;RoundUP: &quot;,#Watt,CR,LF)

Readout from SERTXD
At 13.62 * 4.5 SERTXD shows &quot;6133&quot; where it should have shown 613
Ved 13.62 * 0.8 SERTXD shows &quot;1108&quot; where it should have shown 111

Calculatation example with a calculator

At 13.62 * 4.5 = 6129 But want the result rounded up tol 613
At 13.62 * 0.8 = 1089 But want the result rounded up to 109
</font></pre></code>

Can you help me with a suggestion to improve my codes or a better suggestion for rounding up

A code example would be great ;-)

Best regards
Monie
 

Dippy

Moderator
I may be missing something crucial (as I only looked at it for 3 seconds) but why can't you have:
Watt = Watt + RestOprund + 5
watt = watt/10

The normal method of rounding is to add 5 in the next column and divide by 10 (and int it if on a PC).
 
Top