Post Scarcity
A prototype for a post scarcity programming environment
Loading...
Searching...
No Matches
real.c
Go to the documentation of this file.
1
/*
2
* real.c
3
*
4
* functions for real number cells.
5
*
6
* (c) 2017 Simon Brooke <simon@journeyman.cc>
7
* Licensed under GPL version 2.0, or, at your option, any later version.
8
*/
9
10
#include "
memory/conspage.h
"
11
#include "
memory/consspaceobject.h
"
12
#include "
debug.h
"
13
#include "
io/read.h
"
14
15
/**
16
* Allocate a real number cell representing this value and return a cons
17
* pointer to it.
18
* @param value the value to wrap;
19
* @return a real number cell wrapping this value.
20
*/
21
struct
cons_pointer
make_real
( long double value ) {
22
struct
cons_pointer
result =
allocate_cell
(
REALTV
);
23
struct
cons_space_object
*cell = &
pointer2cell
( result );
24
cell->
payload
.real.value = value;
25
26
debug_dump_object
( result,
DEBUG_ARITH
);
27
28
return
result;
29
}
allocate_cell
struct cons_pointer allocate_cell(uint32_t tag)
Allocates a cell with the specified tag.
Definition
conspage.c:222
conspage.h
consspaceobject.h
cons_space_object::payload
union cons_space_object::@3 payload
REALTV
#define REALTV
The string REAL, considered as an unsigned int.
Definition
consspaceobject.h:199
pointer2cell
#define pointer2cell(pointer)
given a cons_pointer as argument, return the cell.
Definition
consspaceobject.h:297
cons_pointer
An indirect pointer to a cons cell.
Definition
consspaceobject.h:415
cons_space_object
an object in cons space.
Definition
consspaceobject.h:626
debug_dump_object
void debug_dump_object(struct cons_pointer pointer, int level)
Like dump_object, q.v., but protected by the verbosity mechanism.
Definition
debug.c:136
debug.h
DEBUG_ARITH
#define DEBUG_ARITH
Print messages debugging arithmetic operations.
Definition
debug.h:28
read.h
make_real
struct cons_pointer make_real(long double value)
Allocate a real number cell representing this value and return a cons pointer to it.
Definition
real.c:21
workspace
post-scarcity
src
arith
real.c
Generated by
1.9.8