\doxysection{peano.\+h}
\hypertarget{peano_8h_source}{}\label{peano_8h_source}\index{workspace/post-\/scarcity/src/arith/peano.h@{workspace/post-\/scarcity/src/arith/peano.h}}
\mbox{\hyperlink{peano_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00001}00001\ \textcolor{comment}{/*}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00002}00002\ \textcolor{comment}{\ *\ peano.h}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00003}00003\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00004}00004\ \textcolor{comment}{\ *\ Basic\ peano\ arithmetic}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00005}00005\ \textcolor{comment}{\ *}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00006}00006\ \textcolor{comment}{\ *\ (c)\ 2017\ Simon\ Brooke\ <simon@journeyman.cc>}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00007}00007\ \textcolor{comment}{\ *\ Licensed\ under\ GPL\ version\ 2.0,\ or,\ at\ your\ option,\ any\ later\ version.}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00008}00008\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00009}00009\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00010}00010\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00011}00011\ \textcolor{preprocessor}{\#ifndef\ PEANO\_H}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00012}00012\ \textcolor{preprocessor}{\#define\ PEANO\_H}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00013}00013\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00014}00014\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{consspaceobject_8h}{memory/consspaceobject.h}}"{}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00015}00015\ \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00016}00016\ \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00017}00017\ \textcolor{comment}{\ *\ The\ maximum\ value\ we\ will\ allow\ in\ an\ integer\ cell:\ one\ less\ than\ 2\string^60:}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00018}00018\ \textcolor{comment}{\ *\ (let\ ((s\ (make-\/string-\/output-\/stream)))}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00019}00019\ \textcolor{comment}{\ *\ \ \ (format\ s\ "{}0x0\string~XL"{}\ (-\/\ (expt\ 2\ 60)\ 1))}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00020}00020\ \textcolor{comment}{\ *\ \ \ (string-\/downcase\ (get-\/output-\/stream-\/string\ s)))}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00021}00021\ \textcolor{comment}{\ *\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ "{}0x0fffffffffffffffl"{}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00022}00022\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00023}00023\ \textcolor{comment}{\ *\ So\ left\ shifting\ and\ right\ shifting\ by\ 60\ bits\ is\ correct.}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00024}00024\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00025}\mbox{\hyperlink{peano_8h_a1d7315d4ead5ca96f165f5f309220e5b}{00025}}\ \textcolor{preprocessor}{\#define\ MAX\_INTEGER\ \ \ ((\_\_int128\_t)0x0fffffffffffffffL)}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00026}\mbox{\hyperlink{peano_8h_ae4eb2d741f133542824727acb617b027}{00026}}\ \textcolor{preprocessor}{\#define\ INT\_CELL\_BASE\ ((\_\_int128\_t)MAX\_INTEGER\ +\ 1)\ }\textcolor{comment}{//\ ((\_\_int128\_t)0x1000000000000000L)}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00027}00027\ \textcolor{comment}{}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00028}00028\ \textcolor{comment}{/**}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00029}00029\ \textcolor{comment}{\ *\ @brief\ Number\ of\ value\ bits\ in\ an\ integer\ cell}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00030}00030\ \textcolor{comment}{\ *\ }}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00031}00031\ \textcolor{comment}{\ */}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00032}\mbox{\hyperlink{peano_8h_affebeb503d1bd3d7aaa35b44668a34b6}{00032}}\ \textcolor{preprocessor}{\#define\ INTEGER\_BIT\_SHIFT\ (60)}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00033}00033\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00034}00034\ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{peano_8h_af8dcf18e0b388a11b07727063f989b9c}{zerop}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00035}00035\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00036}00036\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_a471edde763902818d541e02cb9d83b60}{negative}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00037}00037\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00038}00038\ \textcolor{keywordtype}{bool}\ \mbox{\hyperlink{peano_8h_a55136259512dc90fc104a2670505f172}{is\_negative}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00039}00039\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00040}00040\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_a2bdf13db14973c9ad70e6e95313b27ad}{absolute}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00041}00041\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00042}00042\ \textcolor{keywordtype}{long}\ \textcolor{keywordtype}{double}\ \mbox{\hyperlink{peano_8h_ac3f5af65c887eed123b7be986ae92766}{to\_long\_double}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00043}00043\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00044}00044\ int64\_t\ \mbox{\hyperlink{peano_8h_aff092cc8ce6153b70eddb7ed82238034}{to\_long\_int}}(\ \textcolor{keyword}{struct}\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00045}00045\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00046}00046\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_a15e9658945908b10ad1af9a3d3f39df4}{lisp\_absolute}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00047}00047\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *frame,\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,\ struct}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00048}00048\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00049}00049\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00050}00050\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00051}00051\ \mbox{\hyperlink{peano_8h_acd39b881664912e10260d4cbabece7e6}{lisp\_add}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00052}00052\ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00053}00053\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00054}00054\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_a690b85053e51efeb8543eec37c231d3a}{lisp\_is\_negative}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00055}00055\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ *frame,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00056}00056\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,\ struct}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00057}00057\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00058}00058\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00059}00059\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00060}00060\ \mbox{\hyperlink{peano_8h_ac810209ae8dc6f873611fa97d8e6e8cf}{lisp\_multiply}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00061}00061\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00062}00062\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00063}00063\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_a471edde763902818d541e02cb9d83b60}{negative}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00064}00064\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00065}00065\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_ada1a2eed62b49481aad0121f3a88e484}{subtract\_2}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00066}00066\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00067}00067\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg1,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00068}00068\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ arg2\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00069}00069\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00070}00070\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00071}00071\ \mbox{\hyperlink{peano_8h_aa9936243c68951d23dfda5b55ad1ea57}{lisp\_subtract}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00072}00072\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,\ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00073}00073\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00074}00074\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00075}00075\ \mbox{\hyperlink{peano_8h_ab582e06c65cc44e9d3acdc264cf9ca8f}{lisp\_divide}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00076}00076\ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00077}00077\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00078}00078\ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ \mbox{\hyperlink{peano_8h_a660689501f2a386b1434e4322b189804}{lisp\_ratio\_to\_real}}(\ struct\ \mbox{\hyperlink{consspaceobject_8h_structstack__frame}{stack\_frame}}\ *frame,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00079}00079\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{struct\ }\mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ frame\_pointer,}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00080}00080\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ struct\ \mbox{\hyperlink{consspaceobject_8h_structcons__pointer}{cons\_pointer}}\ env\ );}
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00081}00081\ }
\DoxyCodeLine{\Hypertarget{peano_8h_source_l00082}00082\ \textcolor{preprocessor}{\#endif\ }\textcolor{comment}{/*\ PEANO\_H\ */}\textcolor{preprocessor}{}}

\end{DoxyCode}
