123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- (defconst exp-base 2 "\
- Base of exponent in this floating point representation.")
- (defconst mantissa-bits 24 "\
- Number of significant bits in this floating point representation.")
- (defconst decimal-digits 6 "\
- Number of decimal digits expected to be accurate.")
- (defconst expt-digits 2 "\
- Maximum permitted digits in a scientific notation exponent.")
- (defconst maxbit (1- mantissa-bits) "\
- Number of highest bit")
- (defconst mantissa-maxval (1- (ash 1 maxbit)) "\
- Maximum permissable value of mantissa")
- (defconst mantissa-minval (ash 1 maxbit) "\
- Minimum permissable value of mantissa")
- (defconst floating-point-regexp "^[ ]*\\(-?\\)\\([0-9]*\\)\\(\\.\\([0-9]*\\)\\|\\)\\(\\(\\([Ee]\\)\\(-?\\)\\([0-9][0-9]*\\)\\)\\|\\)[ ]*$" "\
- Regular expression to match floating point numbers. Extract matches:
- 1 - minus sign
- 2 - integer part
- 4 - fractional part
- 8 - minus sign for power of ten
- 9 - power of ten
- ")
- (defconst high-bit-mask (ash 1 maxbit) "\
- Masks all bits except the high-order (sign) bit.")
- (defconst second-bit-mask (ash 1 (1- maxbit)) "\
- Masks all bits except the highest-order magnitude bit")
- (setq _f0 (quote (0 . 1)))
- (setq _f1/2 (quote (4194304 . -23)))
- (setq _f1 (quote (4194304 . -22)))
- (setq _f10 (quote (5242880 . -19)))
- (setq powers-of-10 (make-vector (1+ decimal-digits) _f1))
- (aset powers-of-10 1 _f10)
- (aset powers-of-10 2 (quote (6553600 . -16)))
- (aset powers-of-10 3 (quote (8192000 . -13)))
- (aset powers-of-10 4 (quote (5120000 . -9)))
- (aset powers-of-10 5 (quote (6400000 . -6)))
- (aset powers-of-10 6 (quote (8000000 . -3)))
- (setq all-decimal-digs-minval (aref powers-of-10 (1- decimal-digits)) highest-power-of-10 (aref powers-of-10 decimal-digits))
- (defun fashl (fnum) (byte-code "Á@Â\"ASB‡" [fnum ash 1] 3))
- (defun fashr (fnum) (byte-code "Á@Â\"ATB‡" [fnum ash -1] 3))
- (defun normalize (fnum) (byte-code "@ÄVƒ ÅÆ@ \"!… Ç!‰ˆ‚ ‚= @ÄWƒ: ÅÆ@
- \"!…7 Ç!‰ˆ‚$ ‚= ‰ˆ‡" [fnum second-bit-mask high-bit-mask _f0 0 zerop logand fashl] 9))
- (defun abs (n) (byte-code "Á!ƒ
|