On this page:
exact
inexact
min*
max*
ceiling-quotient
ceiling-multiple
floor-quotient
floor-multiple
string->integer
MIN-INT8
MIN-INT16
MIN-INT32
MIN-INT64
MIN-INT128
MIN-INT256
MAX-INT8
MAX-INT16
MAX-INT32
MAX-INT64
MAX-INT128
MAX-INT256
MAX-UINT8
MAX-UINT16
MAX-UINT32
MAX-UINT64
MAX-UINT128
MAX-UINT256
int8?
int16?
int32?
int64?
int128?
int256?
uint8?
uint16?
uint32?
uint64?
uint128?
uint256?
8.16.0.4

11 Numbers🔗ℹ

 (require scramble/number) package: scramble-lib

procedure

(exact r)  number?

  r : number?

procedure

(inexact r)  number?

  r : number?
Aliases for inexact->exact and exact->inexact, respectively.

procedure

(min* r ...)  real?

  r : real?

procedure

(max* r ...)  real?

  r : real?
Like min and max, respectively, but they return the appropriate infinity if given zero arguments, and comparisons against +inf.0 and -inf.0 do not coerce the result to inexact.

Examples:
> (min 1 +inf.0) ; normal min

1.0

> (min* 1 +inf.0)

1

> (min* 1 2.0)

1.0

> (max*)

-inf.0

Equivalent to (ceiling (/ n d)), but avoids the intermediate rational result.

Examples:
> (ceiling-quotient 7 4)

2

> (ceiling-quotient 8 4)

2

> (ceiling-quotient 9 4)

3

Returns the least multiple of d greater than or equal to n.

Equivalent to (* d (ceiling-quotient n d)).

Examples:
> (ceiling-multiple 7 4)

8

> (ceiling-multiple 8 4)

8

> (ceiling-multiple 9 4)

12

procedure

(floor-quotient n d)  exact-integer?

  n : exact-integer?
  d : exact-positive-integer?

procedure

(floor-multiple n d)  exact-integer?

  n : exact-integer?
  d : exact-positive-integer?
Equivalent to (floor (/ n d)) and (* d (floor-quotient n d)), respectively.

procedure

(string->integer s    
  [#:min min-value    
  #:max max-value])  (or/c exact-integer? #f)
  s : string?
  min-value : real? = -inf.0
  max-value : real? = +inf.0
Returns the exact integer represented by s if it is in the range [min-value, max-value]; otherwise, returns #f.

Examples:
> (string->integer "123" #:min 0 #:max 100)

#f

> (string->integer "123" #:min 0 #:max 500)

123

> (string->integer "1e3") ; exponentials are not allowed

#f

> (string->integer "#x10") ; radix markers are not allowed

#f

Added in version 0.4 of package scramble-lib.

value

MIN-INT8 : exact-integer? = (- (expt 2 7))

value

MIN-INT16 : exact-integer? = (- (expt 2 15))

value

MIN-INT32 : exact-integer? = (- (expt 2 31))

value

MIN-INT64 : exact-integer? = (- (expt 2 63))

value

MIN-INT128 : exact-integer? = (- (expt 2 127))

value

MIN-INT256 : exact-integer? = (- (expt 2 255))

Minimum integer representable as signed (two’s complement) in 8, 16, 32, 64, 128, and 256 bits, respectively.

Added in version 0.4 of package scramble-lib.

value

MAX-INT8 : exact-integer? = (sub1 (expt 2 7))

value

MAX-INT16 : exact-integer? = (sub1 (expt 2 15))

value

MAX-INT32 : exact-integer? = (sub1 (expt 2 31))

value

MAX-INT64 : exact-integer? = (sub1 (expt 2 63))

value

MAX-INT128 : exact-integer? = (sub1 (expt 2 127))

value

MAX-INT256 : exact-integer? = (sub1 (expt 2 255))

Maximum integer representable as signed (two’s complement) in 8, 16, 32, 64, 128, and 256 bits, respectively.

Added in version 0.4 of package scramble-lib.

value

MAX-UINT8 : exact-integer? = (sub1 (expt 2 16))

value

MAX-UINT16 : exact-integer? = (sub1 (expt 2 16))

value

MAX-UINT32 : exact-integer? = (sub1 (expt 2 32))

value

MAX-UINT64 : exact-integer? = (sub1 (expt 2 64))

value

MAX-UINT128 : exact-integer? = (sub1 (expt 2 128))

value

MAX-UINT256 : exact-integer? = (sub1 (expt 2 256))

Maximum integer representable as unsigned in 8, 16, 32, 64, 128, and 256 bits, respectively.

Added in version 0.4 of package scramble-lib.

procedure

(int8? v)  boolean?

  v : any/c

procedure

(int16? v)  boolean?

  v : any/c

procedure

(int32? v)  boolean?

  v : any/c

procedure

(int64? v)  boolean?

  v : any/c

procedure

(int128? v)  boolean?

  v : any/c

procedure

(int256? v)  boolean?

  v : any/c
Returns #t if v is an exact integer representable as signed (two’s complement) using 8, 16, 32, 64, 128, or 256 bits, respectively; otherwise, returns #f.

Added in version 0.4 of package scramble-lib.

procedure

(uint8? v)  boolean?

  v : any/c

procedure

(uint16? v)  boolean?

  v : any/c

procedure

(uint32? v)  boolean?

  v : any/c

procedure

(uint64? v)  boolean?

  v : any/c

procedure

(uint128? v)  boolean?

  v : any/c

procedure

(uint256? v)  boolean?

  v : any/c
Returns #t if v is an exact nonnegative integer representable as unsigned using 8, 16, 32, 64, 128, or 256 bits, respectively; otherwise, returns #f.

Added in version 0.4 of package scramble-lib.