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"
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 */
21struct 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
27
28 return result;
29}
struct cons_pointer allocate_cell(uint32_t tag)
Allocates a cell with the specified tag.
Definition conspage.c:222
union cons_space_object::@3 payload
#define REALTV
The string REAL, considered as an unsigned int.
#define pointer2cell(pointer)
given a cons_pointer as argument, return the cell.
An indirect pointer to a cons cell.
an object in cons space.
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
#define DEBUG_ARITH
Print messages debugging arithmetic operations.
Definition debug.h:28
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