in reply to Re^2: Most Significant Set Bit
in thread Most Significant Set Bit

Strangely using a stored $log2 = log(2) in the above test did not improve the log function speed. It was actually slightly slower.

EDIT: similar also with use constant log2 => log(2)

EDIT2: The interpreter must compile such constant expressions into a constant before running.

Replies are listed 'Best First'.
Re^4: Most Significant Set Bit
by ikegami (Patriarch) on Mar 18, 2024 at 15:05 UTC

    The interpreter must compile such constant expressions into a constant before running.

    Yes

    $ perl -MO=Concise,-exec -e'my $x = log(2);' 1 <0> enter v 2 <;> nextstate(main 1 -e:1) v:{ 3 <$> const[NV 0.693147180559945] s/FOLD 4 <1> padsv_store[$x:1,2] vKS/LVINTRO 5 <@> leave[1 ref] vKP/REFC -e syntax OK