aussieplusplus icon indicating copy to clipboard operation
aussieplusplus copied to clipboard

Numerical improvements

Open bbrk24 opened this issue 2 years ago • 2 comments

Should we consider bitwise operators? I imagine << and >> will run into parsing issues, but |, &, ^, and ~ should be doable. Alternatively, we could use words for all six. (I have no suggestions for what.)

Why does !0 == !1? They both evaluate to YEAH, NAH! which doesn't make sense to me. Typically, 0 corresponds to one boolean and all other integers to the other. This isn't always completely accurate -- for example, Objective-C does this mod 256 -- but I'd say it's pretty uncontroversial that 0 and 1 should have different boolean values.

Should we have literals for NaN and Infinity? It is possible to get them (0 / 0 and 1 / 0 respectively) but I'd prefer them to have names. They currently print as NaN and inf respectively, so if we give them names then the string conversion has to be updated to match.

The syntax highlighting shows literals like 1e9 as if they're numbers, but they don't work: OI MATE! EXPECTED ; BUT GOT 'e9'. It would be nice to be able to express large or small numbers using scientific notation, or have an exponentation operation (like pow() or **) -- preferably both.

bbrk24 avatar Mar 18 '22 04:03 bbrk24

~ should be doable.

I forgot that it's already being used for pattern matching. I don't know how much of a problem that would be.

bbrk24 avatar Mar 18 '22 22:03 bbrk24

G'DAY MATE!

I RECKON inf = 1 / 0;
GIMME inf == inf;

CHEERS C***!

Gives Yeah, nah!. x != x is the typical test for NaN; generally Infinity == Infinity.

bbrk24 avatar Mar 18 '22 22:03 bbrk24