Ahh I got it, I changed the definition of max from
var Number max = ((heating_morning_maximum_setpoint.state) as DecimalType)
to
var Number max = ((heating_morning_maximum_setpoint.state) as DecimalType).floatValue
and it worked as now it’s a float. I would have thought that DecimalType was already a float type