Changeset 38251 in project


Ignore:
Timestamp:
03/14/20 18:41:42 (2 weeks ago)
Author:
Kon Lovett
Message:

fp% & fp! (joke)

Location:
release/5/fp-utils/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/5/fp-utils/trunk/fp-inlines.scm

    r38106 r38251  
    131131(define (fpprecision-factor p #!optional (base 10.0)) (fpexpt base (exact->inexact p)))
    132132
     133#|
     134;;
     135
     136(: fp% (float float --> float))
     137;
     138(define (fp% n p) (fp/ (fp* 100.0 n) p))
     139|#
     140
    133141) ;fp-inlines
  • release/5/fp-utils/trunk/fp-utils.scm

    r38106 r38251  
    190190(define (fp~>= x y #!optional (eps flonum-epsilon)) (or (fp> x y) (fp~= x y eps)))
    191191
     192#|
     193;;
     194
     195(: fp% (float number --> float))
     196;
     197(define (fp% n p)
     198  (fp* (fp* (exact->inexact p) 0.01) n) )
     199
     200;;
     201
     202(define-constant SQRT5 161/72)
     203
     204(: fibonacci (number --> number))
     205;
     206(define (fibonacci n)
     207  (if (not (positive? n))
     208    0
     209    (floor
     210      (- (* (/ 1 SQRT5) (expt (/ (+ 1 SQRT5) 2) n))
     211         (* (/ 1 SQRT5) (expt (/ (- 1 SQRT5) 2) n)))) ) )
     212
     213;https://oeis.org/A002163
     214(define-constant FPSQRT5 2.23606797749978969640917366873127623544061835961152572427089724541052092563780489941441440837878227)
     215
     216(: fp! (float --> float))
     217;
     218(define (fp! n)
     219  (if (not (fppositive? n))
     220    0.0
     221    (fpfloor
     222      (fp- (fp* (/ 1 FPSQRT5) (expt (fp/ (+ 1 FPSQRT5) 2.0) n))
     223           (fp* (/ 1 FPSQRT5) (expt (fp/ (- 1 FPSQRT5) 2.0) n)))) ) )
     224|#
     225
    192226) ;fp-utils
Note: See TracChangeset for help on using the changeset viewer.