0001 #include <cgreen/boxed_double.h>
0002 #include <stdint.h>
0003 #include <stdlib.h>
0004
0005 #ifdef __cplusplus
0006 namespace cgreen {
0007 #endif
0008
0009
0010 intptr_t box_double(double value) {
0011 BoxedDouble *box = (BoxedDouble *) malloc(sizeof(BoxedDouble));
0012 box->value = value;
0013 return (intptr_t)box;
0014 }
0015
0016 double unbox_double(intptr_t box) {
0017 double value = as_double(box);
0018 free((BoxedDouble *)box);
0019 return value;
0020 }
0021
0022 double as_double(intptr_t box) {
0023 return ((BoxedDouble *)box)->value;
0024 }
0025
0026 #ifdef __cplusplus
0027 }
0028 #endif