4 ms·
> has automatic bigint conversion how can one implement this without a branch before literally any arithmetic operation?
by jcelerier 4y ago
> has automatic bigint conversion
how can one implement this without a branch before literally any arithmetic operation?
- throwawaymaths 4y agoYou're not using Erlang for speed. You're using Erlang for reliability. (Note this is not the same thing as correctness or "safety")
- phoe-krk 4y agoIn CL, you can declare that you need modulo arithmetic, which will give you branchless arithmetic operations. In Erlang, you don't; the language was never made for that sort of speed.
- bitwalker 4y agoErlang checks for overflow after arithmetic ops are performed internally (IIRC), so you are generally only penalized when overflow actually occurs and requires promotion, which probably isn’t much different in performance from a language that would raise an error on overflow, though obviously not as efficient as a language that just wraps around on overflow.