heyman / heynote

A dedicated scratchpad for developers
https://heynote.com
Other
3.86k stars 194 forks source link

Feature request: programmer maths #169

Closed RobChaferDID closed 7 months ago

RobChaferDID commented 7 months ago

Your maths sections can do 'normal' maths. I can type in 0xe0000 and it will show the decimal (although it shows 57.344 when my locale would suggest 57,344). However, I can't type in 57344 and see the hex or binary for it. It would also be nice to do bit operations: 0xe0000^56 for example (for xor).

peterjaric commented 7 months ago

Math.js (that powers the Math blocks) supports functions, and among them there is a hex() function that seems to convert to hex representation of a number. There is also a bin() function.

As for bitwise operations, there is bitAnd and bitXor for example.

heyman commented 7 months ago

Heynote, like most programming languages, use . as decimal character no matter you locale. The , character is used as separator in arrays and matrices.

NoahAndrews commented 7 months ago

You can use the new ability to change the formatting function to make a Math block that gives all results in hex (or another number system). Just start the block off with this:

_format = format
format(x) = _format(x, {notation:"hex"})

Screenshot: image