Subversion Repositories NedoOS

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1485 alone 1
# extended
2
This is an 80-bit float format with a 1-bit sign, 15-bit exponent and 64-bit
3
significand.
4
 
5
# Format
6
`extended` floats are stored in little endian. The "most significant bit" is
7
sign, the next 15 bits are exponent, and the next 64 bits encode the 64-bit
8
significand (note that the top bit of the significand **is** stored explicitly).
9
The exponent is stored with a bias of +16384 (so an exponent of 0 is stored as
10
the literal value 16384). Like the so-called "single" format this library uses,
11
special values +0 ,-0, +inf, -inf, and NaN are stored with an exponent of -16384
12
(literal stored as a 0), and the sign and top two bits of the significand
13
determine which special value it is.
14
 
15
```
16
m is significand
17
e is exponent
18
s is sign
19
- is any value (0 or 1, doesn't matter)
20
 
21
        seeeeeee eeeeeeee mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm
22
+0      00000000 00000000 00------ -------- -------- -------- -------- -------- -------- --------
23
-0      10000000 00000000 00------ -------- -------- -------- -------- -------- -------- --------
24
+inf    00000000 00000000 1------- -------- -------- -------- -------- -------- -------- --------
25
+inf    10000000 00000000 1------- -------- -------- -------- -------- -------- -------- --------
26
NaN     -0000000 00000000 01------ -------- -------- -------- -------- -------- -------- --------
27
 1      01000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
28
 2      01000000 00000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
29
 1      11000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
30
pi      01000000 00000001 11001001 00001111 11011010 10100010 00100001 01101000 11000010 00110101
31
 
32
```
33
 
34
## Input/Output
35
```
36
  x: HL points to the first operand (if any)
37
  y: DE points to the second operand (if any)
38
  t: IX points to the third operand (if any)
39
  z: BC points to the output
40
```
41
There is one notable exception:
42
 
43
* `xcmp` takes float inputs, but returns output in the zero flag and carry flag
44
 
45
## Routines
46
These float routines are for the most part prefixed with `x` to distinguish
47
them from the other float routines in this library. Most of them are in their
48
own file, but some files contain several routines. These cases are noted in the
49
chart below.
50
 
51
```
52
xabs       |x|
53
xacos      acos(x)
54
xacosh     acosh(x)
55
xadd       x+y
56
xamean     (x+y)/2
57
xasin      asin(x)
58
xasinh     asinh(x)
59
xatan      atan(x)
60
xatanh     atanh(x)
61
xbg        1/BG(x,y)  (reciprocal Borchardt-Gauss mean)
62
xcis       {cos(x), sin(x)}
63
xcmp       compare x to y
64
xcos       cos(x)
65
xcosh      cosh(x)
66
xdiv       x/y
67
xdiv2      x/2
68
xexp       e^x
69
xfma       x*y+t
70
xgeomean   sqrt(x*y)
71
xinv       1/x
72
xlg        log2(x)
73
xln        log(x)     (a.k.a. ln(x))
74
xlog       log_y(x)
75
xlog10     log10(x)
76
xmod1      x mod 1
77
xmul       x*y
78
xmul2      x*2  (found in the extended/mul directory)
79
xmul3      x*3  (found in the extended/mul directory)
80
xmul5      x*5  (found in the extended/mul directory)
81
xmul7      x*7  (found in the extended/mul directory)
82
xmul10     x*10 (found in the extended/mul directory)
83
xmul11     x*11 (found in the extended/mul directory)
84
xmul13     x*13 (found in the extended/mul directory)
85
xmul15     x*15 (found in the extended/mul directory)
86
xmul17     x*17 (found in the extended/mul directory)
87
xmul31     x*31 (found in the extended/mul directory)
88
xneg       -x
89
xpow       x^y
90
xpow2      2^x
91
xpow10     10^x
92
xrand      random number on [0,1), uniform distribution
93
xrsub      -x+y
94
xsin       sin(x)
95
xsinh      sinh(x)
96
xsqrt      sqrt(x)
97
xsub       x-y
98
xtan       tan(x)
99
xtanh      tanh(x)
100
strtox     "string" ==> extended float
101
xtostr     string(x)
102
xtoTI      TIFloat(x)
103
TItox      TIFloat ==> extended
104
```
105
 
106
## Example Usage
107
Calculate `10^(pi+e)`:
108
 
109
```
110
  ; Add pi+e
111
  ld hl, const_pi
112
  ld de, const_e
113
  ld bc, xOP1
114
  call xadd
115
 
116
  ; BC points to the output, so want to load BC into HL, then call pow10
117
  ld h, b
118
  ld l, c
119
  call xpow10
120
  ; result is at BC (which is the same as HL and xOP1 here)
121
```