Round number to #.#

I use follow rulescript to get the correct value:

// triggeringItem.state =  1444
val watt = Math::round(((triggeringItem.state as Number)/1000).intValue)

now watt contains only 1 but how can i convert it to #:# ?

i tried follow script but it doesn’t work:

var DecimalFormat df = new DecimalFormat("#.#")
var s = df.format((triggeringItem.state as Number)/1000) 
watt = new DecimalType(s)

I searched again i found a working solution:

	val java.text.DecimalFormat df = new java.text.DecimalFormat("#.#")
	val Number watt = Double.valueOf(df.format((triggeringItem.state as Number)/1000))

Typically the way this is handled is we leave Item with all the decimal places and round the number only when we show them to a user or log.

For an Item’s label, we would use

Number MyItem "MyItem label [%.1f]"

For logging, we would use String::format:

logInfo("Logger Name", String::format("My value %.1f", floatValue))

okay thanks, but this string::format rounding values…
see here:
[vent.ItemStateChangedEvent] - PowerStrip_1_Port_2_Watt_Org changed from 684 to 536
[vent.ItemStateChangedEvent] - PowerStrip_1_Port_2_Watt changed from 0.7 to 0.5

BTW: how can i disable this kind of logging? (this will create up to 24 logs each 4 seconds)
Edit: i try it with the custom conftig from this thread: Log4j2 Sample Config

Regards, Web