Homey Community Forum

List of available Math.js functions

Is there a list of math functions that do work? Not all functions listed on https://mathjs.org/docs/reference/functions.html work. Functions like “{{mean(2, 1, 4, 3)}}” and “{{round(5.345,2)}}” work flawlessly, but but XOR (like {{ xor(8, 2) }}), OR and AND do not seem to work. Or am I missing something?

I’m looking for a way to do some bitwise operations in flows.

Any help is greatly apprecieated.

Hmmm, bitwise operations can be down with the “|”, “&” and “^ signs.” So calculating a variable goes like this:

8th bit => On: OR 10000000 / Off: AND 01111111 => On {{Warmtevraag |128}} / Off {{Warmtevraag |127}}
7th bit => On: OR 01000000 / Off: AND 10111111 => On {{Warmtevraag |64}} / Off {{Warmtevraag |191}}
6th bit => On: OR 00100000 / Off: AND 11011111 => On {{Warmtevraag |32}} / Off {{Warmtevraag |223}}
5th bit => On: OR 00010000 / Off: AND 11101111 => On {{Warmtevraag |16}} / Off {{Warmtevraag |239}}
4th bit => On: OR 00001000 / Off: AND 11110111 => On {{Warmtevraag |8}} / Off {{Warmtevraag |247}}
3rd bit => On: OR 00000100 / Off: AND 11111011 => On {{Warmtevraag |4}} / Off {{Warmtevraag |251}}
2nd bit => On: OR 00000010 / Off: AND 11111101 => On {{Warmtevraag |2}} / Off {{Warmtevraag |253}}
1st bit => On: OR 00000001 / Off: AND 11111110 => On {{Warmtevraag |1}} / Off {{Warmtevraag |254}}

Still don’t understand why {{Warmtevraag or 1}} and {{Warmtevraag and 254}} don’t work, so still would like to know which math functions are supported. For future reference :slight_smile:

Duplicate topic here.

According to the fine manual, and and or are logical operators, not bitwise operators.

Thanks, that was the list I was looking for.

1 Like