[erlang-questions] Arithmetic expressions [WAS: Re: Binaries problem]
Jim Thompson
jim@REDACTED
Wed May 2 23:20:29 CEST 2007
Kostis Sagonas wrote:
> Jim Thompson wrote:
>> Eshell V5.5.2 (abort with ^G)
>> 1> round(math:pow(2,21))-3.
>> 2097149
>
> Unrelated to the topic, but we had weird cases where the HiPE compiler
> was crashing when compiling binaries in R11B-3. They were all related
> to use of an expression that was similar to the one Jim is using:
>
> round(math:pow(2,N)) - K.
>
> In examining the problem, we realized that this was a very stupid way of
> denoting this quantity. We solved the problem (in R11B-4) by adopting a
> much better (and significantly faster) way of writing the same
> expression in Erlang:
>
> (2 bsl (N-1)) - K
>
> I suspect this "round + math:pow(2)" combination is not so uncommon
> after all ... although there is really no reason to use it.
I am an Erlang newbie, and therefore stupid. Ignore what I say, or type.
More information about the erlang-questions
mailing list