Changeset 13562 in project for chicken


Ignore:
Timestamp:
03/07/09 17:08:16 (11 years ago)
Author:
Kon Lovett
Message:

Added fixnum & flonum limit constants.

Location:
chicken/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/library.scm

    r13304 r13562  
    4141#include <errno.h>
    4242#include <time.h>
     43#include <float.h>
    4344
    4445#ifdef HAVE_SYSEXITS_H
     
    733734;;; Numeric routines:
    734735
     736(define most-positive-fixnum (foreign-value "C_MOST_POSITIVE_FIXNUM" int))
     737(define most-negative-fixnum (foreign-value "C_MOST_NEGATIVE_FIXNUM" int))
     738(define fixnum-bits (foreign-value "(C_WORD_SIZE - 1)" int))
     739(define fixnum-precision (foreign-value "(C_WORD_SIZE - (1 + 1))" int))
     740
    735741(define (fixnum? x) (##core#inline "C_fixnump" x))
    736742(define (fx+ x y) (##core#inline "C_fixnum_plus" x y))
     
    769775    (fx-check-divison-by-zero x y 'fxmod)
    770776    (##core#inline "C_fixnum_modulo" x y) ] ) )
     777
     778(define maximum-flonum (foreign-value "DBL_MAX" double))
     779(define minimum-flonum (foreign-value "DBL_MIN" double))
     780(define flonum-radix (foreign-value "FLT_RADIX" int))
     781(define flonum-epsilon (foreign-value "DBL_EPSILON" double))
     782(define flonum-precision (foreign-value "DBL_MANT_DIG" int))
     783(define flonum-decimal-precision (foreign-value "DBL_DIG" int))
     784(define flonum-maximum-exponent (foreign-value "DBL_MAX_EXP" int))
     785(define flonum-minimum-exponent (foreign-value "DBL_MIN_EXP" int))
     786(define flonum-maximum-decimal-exponent (foreign-value "DBL_MAX_10_EXP" int))
     787(define flonum-minimum-decimal-exponent (foreign-value "DBL_MIN_10_EXP" int))
    771788
    772789(define (flonum? x) (##core#inline "C_i_flonump" x))
  • chicken/trunk/manual/Unit library

    r11989 r13562  
    1616
    1717Adds/subtracts 1 from {{N}}.
     18
    1819
    1920==== Binary integer operations
     
    3839set, or {{#f}} otherwise. The rightmost/least-significant bit is bit 0.
    3940
    40 
    41 ==== fixnum?
    42 
    43  [procedure] (fixnum? X)
    44 
    45 Returns {{#t}} if {{X}} is a fixnum, or {{#f}} otherwise.
    4641
    4742==== Arithmetic fixnum operations
     
    7671; [procedure] (fxshr N1 N2)
    7772
     73==== fixnum?
     74
     75 [procedure] (fixnum? X)
     76
     77Returns {{#t}} if {{X}} is a fixnum, or {{#f}} otherwise.
     78
     79==== Fixnum limits
     80
     81{{most-positive-fixnum}}
     82{{most-negative-fixnum}}
     83{{fixnum-bits}}
     84{{fixnum-precision}}
     85
    7886
    7987==== Arithmetic floating-point operations
    8088
    81 In safe mode, these procedures throw a type error with non-float
    82 arguments (except {{flonum?}}, which returns {{#f}}). In unsafe mode,
    83 these procedures do not check their arguments. A non-flonum argument
    84 in unsafe mode can crash the system.
     89In safe mode, these procedures throw a type error with non-float arguments. In
     90unsafe mode, these procedures do not check their arguments. A non-flonum
     91argument in unsafe mode can crash the system.
    8592
    8693; [procedure] (flonum? X)
     
    98105; [procedure] (fp<= X Y)
    99106
     107==== flonum?
     108
     109 [procedure] (flonum? X)
     110
     111Returns {{#t}} if {{X}} is a flonum, or {{#f}} otherwise.
     112
     113==== Flonum limits
     114
     115{{maximum-flonum}}
     116{{minimum-flonum}}
     117{{flonum-radix}}
     118{{flonum-epsilon}}
     119{{flonum-precision}}
     120{{flonum-decimal-precision}}
     121{{flonum-maximum-exponent}}
     122{{flonum-minimum-exponent}}
     123{{flonum-maximum-decimal-exponent}}
     124{{flonum-minimum-decimal-exponent}}
     125
     126==== finite?
     127
     128 [procedure] (finite? N)
     129
     130Returns {{#f}} if {{N}} is negative or positive infinity, and {{#t}} otherwise.
     131
    100132==== signum
    101133
     
    104136Returns {{1}} if {{N}} is positive, {{-1}} if {{N}}
    105137is negative or {{0}} if {{N}} is zero. {{signum}} is exactness preserving.
    106 
    107 
    108 ==== finite?
    109 
    110  [procedure] (finite? N)
    111 
    112 Returns {{#f}} if {{N}} is negative or positive infinity, and {{#t}} otherwise.
    113138
    114139
Note: See TracChangeset for help on using the changeset viewer.