Maths problem with function node

I'm having problems with the function node which is not subtracting correctly, ie the below code gives the result of: 2.1899999999999977
msg.payload=26.54-24.35;
return msg;

Any help appreciated.

This is the flow:

[{"id":"a617c53a.3aac1","type":"inject","z":"bc64dfd3.f61d1","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":1740,"wires":[["47b21e34.380cb8"]]},{"id":"47b21e34.380cb8","type":"function","z":"bc64dfd3.f61d1","name":"","func":"msg.payload=26.54-24.35;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":900,"y":1740,"wires":[["34ee6374.ca611c"]]},{"id":"34ee6374.ca611c","type":"debug","z":"bc64dfd3.f61d1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1100,"y":1740,"wires":}]

Hi @rich_node

welcome to the forum.

You're hitting a side effect of how JavaScript represents numbers internally. This blog post provides a good explanation: http://adripofjavascript.com/blog/drips/avoiding-problems-with-decimal-math-in-javascript.html

For future reference, please have a read of this post that explains how to share code and flows in the forum: How to share code or flow json

Thank you and appreciate the guidance on using this forumn.