Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
integer.h
Go to the documentation of this file.
1/*
2 * integer.h
3 *
4 * functions for integer cells.
5 *
6 *
7 * (c) 2017 Simon Brooke <simon@journeyman.cc>
8 * Licensed under GPL version 2.0, or, at your option, any later version.
9 */
10
11#ifndef __integer_h
12#define __integer_h
13
14#include <stdbool.h>
15#include <stdint.h>
16
17#define replace_integer_i(p,i) {struct cons_pointer __p = acquire_integer(i,NIL); release_integer(p); p = __p;}
18#define replace_integer_p(p,q) {struct cons_pointer __p = p; release_integer( p); p = q;}
19
20struct cons_pointer make_integer( int64_t value, struct cons_pointer more );
21
22struct cons_pointer acquire_integer( int64_t value, struct cons_pointer more );
23
24void release_integer( struct cons_pointer p );
25
27 struct cons_pointer b );
28
30 struct cons_pointer b );
31
32struct cons_pointer integer_to_string( struct cons_pointer int_pointer,
33 int base );
34
35bool equal_integer_integer( struct cons_pointer a, struct cons_pointer b );
36
37bool equal_integer_real( struct cons_pointer a, struct cons_pointer b );
38
39#endif
An indirect pointer to a cons cell.
bool equal_integer_integer(struct cons_pointer a, struct cons_pointer b)
true if a and be are both integers whose value is the same value.
Definition integer.c:511
bool equal_integer_real(struct cons_pointer a, struct cons_pointer b)
Private function, don't use.
Definition equal.c:87
struct cons_pointer multiply_integers(struct cons_pointer a, struct cons_pointer b)
Return a pointer to an integer representing the product of the integers pointed to by a and b.
Definition integer.c:343
void release_integer(struct cons_pointer p)
if the value of p is less than the size of the small integer cache (and thus it was presumably suppli...
Definition integer.c:163
struct cons_pointer add_integers(struct cons_pointer a, struct cons_pointer b)
Return a pointer to an integer representing the sum of the integers pointed to by a and b.
Definition integer.c:224
struct cons_pointer integer_to_string(struct cons_pointer int_pointer, int base)
return a string representation of this integer, which may be a bignum.
Definition integer.c:454
struct cons_pointer acquire_integer(int64_t value, struct cons_pointer more)
Supply small valued integers from the small integer cache, if available.
Definition integer.c:129
struct cons_pointer make_integer(int64_t value, struct cons_pointer more)
Allocate an integer cell representing this value and return a cons_pointer to it.
Definition integer.c:89