
—— Suggestion ——
— Unified Numbers —
A new type which forms a common metaclass of ints and floats:
Number := Int(x) | Float(x) | Inf | -Inf | NaN
— Unified Operators —
No more dot affix for float operations! Instead, type conversion of ints to floats when floats are involved.
Int + Int -> Int
Int + Float -> Float
Float + Int -> Float
Float + Float -> Float
Same type handling for “-”, “*”, “/” and “**”.
Standard Division is “/” and returns “NaN” for division by zero.
Floor Division is “/.” (repurposed operator) and goes like this:
Int /. Int -> Int
Int /. Float -> Float
Float /. Int -> Int
Float /. Float -> Float
Floor Division by floats: Number of steps by the right operand furthest away from 0 possible without going beyond the left operand.
Floor Division allows for flooring a float to an int: x /. 1 -> z where “x” is any float and “z” is the resulting int.
— Infix Exponentiation —
Int ** Int -> Int
Int ** Float -> Float
Float ** Int -> Float
Float ** Float -> Float
Same type handling as “+”.
— Infinities and Invalid —
“Inf”, “-Inf” and “NaN”: Edge cases may be discussed in the community!
— Positive and Negative Zeros —
They may be necessary for better compatibility with JavaScript’s floating point numbers and to better handle edge cases with infinities. If added, please discuss the possible cases here too!
— Unified Library —
New module for Unified Numbers (best named “number” or “math”), merging the “int” and “float” libraries into one, removing current de facto duplicates and keeping all the functions from both.
— No Curly Braces for Grouping —
Nesting is already reduced with the pipeline operator so parentheses are perfectly fine! They are also easier on the eyes when reading arithmetic computations and correspond to mathematical notation.
#768594524158427168 #general #math #number #int #float #types