Add truly sinful float hacks for Watcom

This commit is contained in:
Lassi Kortela 2019-08-21 22:11:05 +03:00
parent 439eeb2b06
commit 6ffe6bf174
2 changed files with 14 additions and 3 deletions

View File

@ -24,6 +24,11 @@ float F_NINF;
int locale_is_utf8;
#ifdef __WATCOMC__
static float purkka(const char *s, char **dummy) { return strtod(s, dummy); }
#define strtof purkka
#endif
void llt_init()
{
locale_is_utf8 = u8_is_locale_utf8(setlocale(LC_ALL, ""));
@ -36,6 +41,7 @@ void llt_init()
D_NNAN = -strtod("+NaN", NULL);
D_PINF = strtod("+Inf", NULL);
D_NINF = strtod("-Inf", NULL);
F_PNAN = strtof("+NaN", NULL);
F_NNAN = -strtof("+NaN", NULL);
F_PINF = strtof("+Inf", NULL);

View File

@ -1,6 +1,11 @@
extern double trunc(double x);
static double fpart(double arg) { return arg - trunc(arg); }
static double fpart(double arg)
{
if (arg >= 0) {
return arg - floor(arg);
} else {
return arg - ceil(arg);
}
}
// given a number, determine an appropriate type for storing it
#if 0