It's verification time!!!
#19
Math Functions

Code: (Select All)
proc SYSTEM_BUS_T.k_f(x as float) as float
    return x*x
end proc

proc SYSTEM_BUS_T.k_frexp(d as float, ep as float ptr) as float

static as Cheat x

if(d = 0) then
*ep = 0
return 0
end if
x.d = d
*ep = ((x.ms shr K_SHIFT) and K_MASK) - K_BIAS
x.ms = x.ms and  not (K_MASK shl K_SHIFT)
x.ms = x.ms or K_BIAS shl K_SHIFT
return x.d
end proc

proc SYSTEM_BUS_T.k_ldexp(d as float, e as float) as float

static as Cheat x

if(d = 0) then
return 0
end if
x.d = d
e += (x.ms shr K_SHIFT) and K_MASK
if(e <= 0) then
return 0         /' underflow '/
    end if
if(e >= K_MASK) then /' overflow '/
if(d < 0) then
return NEG_INF
end if
return POS_INF
end if
x.ms = x.ms and  not (K_MASK shl K_SHIFT)
x.ms = x.ms or e shl K_SHIFT
return x.d
end proc

proc SYSTEM_BUS_T.k_sqrt(arg as float) as float
static as float x, temp
static as float _exp, i

if(arg <= 0) then
if(arg < 0) then
return 0.0
    end if
return 0
end if
x = k_frexp(arg, @_exp)
while(x < 0.5)
x *= 2
_exp = _exp - 1
wend
/'
' NOTE
' this wont work on 1's comp
'/
if(_exp and 1) then
x *= 2
_exp = _exp - 1
end if
temp = 0.5 * (1.0+x)

while(_exp > 60)
temp *= (1L shl 30)
_exp -= 60
wend

while(_exp < -60)
temp /= (1L shl 30)
_exp += 60
wend

if(_exp >= 0) then
temp *= 1L shl (_exp/2)
else
temp /= 1L shl (-_exp/2)
end if
for i=0 to 4
temp = 0.5*(temp + arg/temp)
next
return temp
end proc
Reply


Messages In This Thread
It's verification time!!! - by fatman2021 - 07-08-2022, 12:16 AM
RE: It's verification time!!! - by fatman2021 - 07-08-2022, 12:07 PM
RE: It's verification time!!! - by bplus - 07-08-2022, 01:00 PM
RE: It's verification time!!! - by dcromley - 07-08-2022, 03:18 PM
RE: It's verification time!!! - by bplus - 07-08-2022, 04:17 PM
RE: It's verification time!!! - by dcromley - 07-08-2022, 05:41 PM
RE: It's verification time!!! - by bplus - 07-08-2022, 05:47 PM
RE: It's verification time!!! - by Kernelpanic - 07-08-2022, 09:50 PM
RE: It's verification time!!! - by fatman2021 - 07-09-2022, 12:20 AM
RE: It's verification time!!! - by fatman2021 - 07-09-2022, 01:30 AM
RE: It's verification time!!! - by fatman2021 - 07-09-2022, 06:01 PM
RE: It's verification time!!! - by fatman2021 - 07-10-2022, 10:13 PM
RE: It's verification time!!! - by fatman2021 - 07-11-2022, 06:26 PM
RE: It's verification time!!! - by fatman2021 - 07-13-2022, 04:50 PM
RE: It's verification time!!! - by fatman2021 - 07-15-2022, 01:43 AM
RE: It's verification time!!! - by fatman2021 - 07-15-2022, 11:30 PM
RE: It's verification time!!! - by fatman2021 - 07-17-2022, 12:56 AM
RE: It's verification time!!! - by fatman2021 - 07-19-2022, 01:14 AM
RE: It's verification time!!! - by fatman2021 - 07-20-2022, 09:52 PM
RE: It's verification time!!! - by dbox - 07-20-2022, 10:07 PM
RE: It's verification time!!! - by fatman2021 - 07-20-2022, 11:24 PM
RE: It's verification time!!! - by vince - 07-21-2022, 01:36 AM
RE: It's verification time!!! - by fatman2021 - 07-21-2022, 06:46 PM
RE: It's verification time!!! - by vince - 07-28-2022, 07:37 AM
RE: It's verification time!!! - by fatman2021 - 07-28-2022, 03:19 PM
RE: It's verification time!!! - by fatman2021 - 07-25-2022, 02:47 AM
RE: It's verification time!!! - by fatman2021 - 07-27-2022, 09:03 PM
RE: It's verification time!!! - by mnrvovrfc - 07-27-2022, 10:08 PM
RE: It's verification time!!! - by fatman2021 - 07-27-2022, 10:50 PM
RE: It's verification time!!! - by fatman2021 - 07-28-2022, 04:04 PM
RE: It's verification time!!! - by fatman2021 - 08-10-2022, 01:13 PM
RE: It's verification time!!! - by fatman2021 - 08-15-2022, 04:50 PM



Users browsing this thread: 1 Guest(s)