Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,44 +1,32 @@
const func float: fltIPow (in var float: base, in var integer: exponent) is func
result
var float: result is 0.0;
var float: power is 1.0;
local
var boolean: neg_exp is FALSE;
var integer: stop is 0;
begin
if base = 0.0 then
if exponent < 0 then
result := Infinity;
elsif exponent = 0 then
result := 1.0;
else
result := 0.0;
power := Infinity;
elsif exponent > 0 then
power := 0.0;
end if;
else
if exponent < 0 then
exponent := -exponent;
neg_exp := TRUE;
stop := -1;
end if;
# In the twos complement representation the most
# negative number is the only one where both the
# number and its negation are negative. When the
# exponent is proven to be to the most negative
# number fltIPow returns 0.0 .
if exponent >= 0 then
if odd(exponent) then
power := base;
end if;
exponent >>:= 1;
while exponent <> stop do
base *:= base;
if odd(exponent) then
result := base;
else
result := 1.0;
power *:= base;
end if;
exponent >>:= 1;
while exponent <> 0 do
base *:= base;
if odd(exponent) then
result *:= base;
end if;
exponent >>:= 1;
end while;
if neg_exp then
result := 1.0 / result;
end if;
end while;
if stop = -1 then
power := 1.0 / power;
end if;
end if;
end func;