Is multiplication faster than division ?

An interesing post by Laurent. Check out http://laurentschneider.com/wordpress/2007/06/to-divide-or-to-multiply.html

My findings on 10gR2 on Windoze XP


SQL> var z number
SQL> var y number
SQL> exec :z := power(2,102)*2e-31;

PL/SQL procedure successfully completed.

SQL> exec :y := 1e125;

PL/SQL procedure successfully completed.

SQL> set timi on
SQL> exec while (:y>1e-125) loop :y:=:y/:z; end loop

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.10
SQL> set timi off
SQL> print y

Y
----------
9.988E-126





SQL> exec :z := power(2,-104)*2e31;

PL/SQL procedure successfully completed.

SQL> exec :y := 1e125;

PL/SQL procedure successfully completed.

SQL> set timi on
SQL> exec while (:y>1e-125) loop :y:=:y*:z; end loop

PL/SQL procedure successfully completed.

Elapsed: 00:00:00.04
SQL> set timi off
SQL> print y

Y
----------
9.988E-126

SQL>

Sidhu

Leave a Reply

Your email address will not be published. Required fields are marked *