00001 #include <common/fixed.h>
00002 #include <stdio.h>
00003 #include <stdlib.h>
00004
00005 #pragma warning(disable:4996)
00006
00007 void fixed_lua_number2str(char *result, int number)
00008 {
00009 fixed f(true, number);
00010 sprintf(result, "%s", f.asString());
00011 }
00012
00013 int fixed_lua_str2number(const char *s, char **endptr)
00014 {
00015 double d = strtod(s, endptr);
00016 fixed f(s);
00017 return f.getInternal();
00018 }
00019
00020 int fixed_lua_number2int(int n)
00021 {
00022 fixed f(true, n);
00023 return f.asInt();
00024 }
00025
00026 int fixed_luai_nummul(int a, int b)
00027 {
00028 fixed fa(true, a);
00029 fixed fb(true, b);
00030 fixed result = fa * fb;
00031 return result.getInternal();
00032 }
00033
00034 int fixed_luai_numdiv(int a, int b)
00035 {
00036 fixed fa(true, a);
00037 fixed fb(true, b);
00038 fixed result = fa / fb;
00039 return result.getInternal();
00040 }
00041
00042 int fixed_luai_nummod(int a, int b)
00043 {
00044 fixed fa(true, a);
00045 fixed fb(true, b);
00046 fixed result = fa % fb;
00047 return result.getInternal();
00048 }
00049
00050 int fixed_luai_numpow(int a, int b)
00051 {
00052 fixed fa(true, a);
00053 fixed fb(true, b);
00054 fixed result = fa.pow(fb);
00055 return result.getInternal();
00056 }