potion  0.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
number.c File Reference

simple arithmetic. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include "potion.h"
#include "internal.h"
+ Include dependency graph for number.c:

Go to the source code of this file.

Macros

#define PN_NUM_MATH(math_op)
 
#define PN_INT_MATH(math_op)
 
#define PN_DBL_MATH(math_op)
 

Functions

PN potion_double (Potion *P, double v)
 new PNDouble (double) More...
 
PN potion_strtod (Potion *P, char *str, int len)
 Convert string to double. More...
 
void potion_num_init (Potion *P)
 

Detailed Description

simple arithmetic.

PNNumber is either an immediate PN_INT integer (with one bit for a tag, range 2^30/2^62) or a boxed full-precision double PNDouble.

Definition in file number.c.

Macro Definition Documentation

#define PN_NUM_MATH (   math_op)
Value:
if (PN_IS_INT(self) && PN_IS_INT(num)) \
return PN_NUM(PN_INT(self) math_op PN_INT(num)); \
return potion_double(P, PN_DBL(self) math_op PN_DBL(num));
PN potion_double(Potion *P, double v)
new PNDouble (double)
Definition: number.c:17
#define PN_INT(x)
Definition: potion.h:205
#define PN_NUM(i)
Definition: potion.h:204
#define PN_DBL(num)
Definition: potion.h:206
#define DBG_CHECK_NUM(obj)
Definition: potion.h:187
#define PN_IS_INT(v)
Definition: potion.h:162

Definition at line 47 of file number.c.

#define PN_INT_MATH (   math_op)
Value:
return PN_NUM(PN_INT(self) math_op PN_INT(num));
#define PN_INT(x)
Definition: potion.h:205
#define PN_NUM(i)
Definition: potion.h:204
#define DBG_CHECK_INT(obj)
Definition: potion.h:188

Definition at line 53 of file number.c.

#define PN_DBL_MATH (   math_op)
Value:
return potion_double(P, PN_DBL(self) math_op PN_DBL(num));
PN potion_double(Potion *P, double v)
new PNDouble (double)
Definition: number.c:17
#define PN_DBL(num)
Definition: potion.h:206
#define DBG_CHECK_NUM(obj)
Definition: potion.h:187

Definition at line 57 of file number.c.

Function Documentation

PN potion_double ( Potion P,
double  v 
)

new PNDouble (double)

Definition at line 17 of file number.c.

PN potion_strtod ( Potion P,
char *  str,
int  len 
)

Convert string to double.

Definition at line 24 of file number.c.

void potion_num_init ( Potion P)

Definition at line 439 of file number.c.