1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
/* Generated by Nim Compiler v2.2.0 */
#define NIM_INTBITS 64
#define NIM_EmulateOverflowChecks
#include "nimbase.h"
#include <math.h>
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
struct NimStrPayload {
NI cap;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
NI len;
NimStrPayload* p;
};
typedef NU8 tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw;
N_LIB_PRIVATE N_NIMCALL(tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw, classify__pureZmath_u211)(NF x_p0);
static N_INLINE(NIM_BOOL, signbit__astyaml_u586)(NF x_p0);
N_LIB_PRIVATE N_NIMCALL(void, addFloatRoundtrip__system_u4800)(NimStringV2* result_p0, NF x_p1);
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1);
static N_INLINE(void, copyMem__system_u1713)(void* dest_p0, void* source_p1, NI size_p2);
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2);
N_LIB_PRIVATE N_NIMCALL(void, prepareAdd)(NimStringV2* s_p0, NI addLen_p1);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(NIM_BOOL, signbit__cgen_u19529)(NF32 x_p0);
N_LIB_PRIVATE N_NIMCALL(void, addFloatRoundtrip__cgen_u19536)(NimStringV2* result_p0, NF32 x_p1);
static const struct {
NI cap; NIM_CHAR data[4+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_2 = { 4 | NIM_STRLIT_FLAG, "-NAN" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_3 = {4, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_2};
static const struct {
NI cap; NIM_CHAR data[3+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_4 = { 3 | NIM_STRLIT_FLAG, "NAN" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_5 = {3, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_4};
static const struct {
NI cap; NIM_CHAR data[4+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_6 = { 4 | NIM_STRLIT_FLAG, "-0.0" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_7 = {4, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_6};
static const struct {
NI cap; NIM_CHAR data[3+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_8 = { 3 | NIM_STRLIT_FLAG, "0.0" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_9 = {3, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_8};
static const struct {
NI cap; NIM_CHAR data[3+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_10 = { 3 | NIM_STRLIT_FLAG, "INF" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_11 = {3, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_10};
static const struct {
NI cap; NIM_CHAR data[4+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_12 = { 4 | NIM_STRLIT_FLAG, "-INF" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_13 = {4, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_12};
static const struct {
NI cap; NIM_CHAR data[0+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_14 = { 0 | NIM_STRLIT_FLAG, "" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_15 = {0, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_14};
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_16 = {0, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_14};
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_17 = {4, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_2};
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_18 = {3, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_4};
static const struct {
NI cap; NIM_CHAR data[5+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_19 = { 5 | NIM_STRLIT_FLAG, "-0.0f" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_20 = {5, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_19};
static const struct {
NI cap; NIM_CHAR data[4+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_21 = { 4 | NIM_STRLIT_FLAG, "0.0f" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_22 = {4, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_21};
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_23 = {3, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_10};
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_24 = {4, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_12};
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_25 = {0, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_14};
static const struct {
NI cap; NIM_CHAR data[1+1];
} TM__mZLUkjbotQF2WK9bQcNKBCA_26 = { 1 | NIM_STRLIT_FLAG, "f" };
static const NimStringV2 TM__mZLUkjbotQF2WK9bQcNKBCA_27 = {1, (NimStrPayload*)&TM__mZLUkjbotQF2WK9bQcNKBCA_26};
extern NIM_BOOL nimInErrorMode__system_u4272;
static N_INLINE(NIM_BOOL, signbit__astyaml_u586)(NF x_p0) {
NIM_BOOL result;
int T1_;
T1_ = (int)0;
T1_ = signbit(x_p0);
result = !((T1_ == ((NI32)0)));
return result;
}
static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) {
void* T1_;
T1_ = (void*)0;
T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2)));
}
static N_INLINE(void, copyMem__system_u1713)(void* dest_p0, void* source_p1, NI size_p2) {
nimCopyMem(dest_p0, source_p1, size_p2);
}
static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1) {
{
if (!(((NI)0) < src_p1.len)) goto LA3_;
copyMem__system_u1713(((void*) ((&(*(*dest_p0).p).data[(*dest_p0).len]))), ((void*) ((&(*src_p1.p).data[((NI)0)]))), ((NI)(src_p1.len + ((NI)1))));
(*dest_p0).len += src_p1.len;
}
LA3_: ;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
NIM_BOOL* result;
result = (&nimInErrorMode__system_u4272);
return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, toStrMaxPrecision__astyaml_u580)(NF f_p0) {
NimStringV2 result;
tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
T1_ = (tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)0;
T1_ = classify__pureZmath_u211(f_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
switch (T1_) {
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)4):
{
{
NIM_BOOL T5_;
T5_ = (NIM_BOOL)0;
T5_ = signbit__astyaml_u586(f_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
if (!T5_) goto LA6_;
result = TM__mZLUkjbotQF2WK9bQcNKBCA_3;
}
goto LA3_;
LA6_: ;
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_5;
}
LA3_: ;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)3):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_7;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)2):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_9;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)5):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_11;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)6):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_13;
}
break;
default:
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_15;
addFloatRoundtrip__system_u4800((&result), f_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
prepareAdd((&result), 0);
appendString((&result), TM__mZLUkjbotQF2WK9bQcNKBCA_16);
}
break;
}
}BeforeRet_: ;
return result;
}
static N_INLINE(NIM_BOOL, signbit__cgen_u19529)(NF32 x_p0) {
NIM_BOOL result;
int T1_;
T1_ = (int)0;
T1_ = signbit(x_p0);
result = !((T1_ == ((NI32)0)));
return result;
}
N_LIB_PRIVATE N_NIMCALL(NimStringV2, toStrMaxPrecision__cgen_u19523)(NF32 f_p0) {
NimStringV2 result;
tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
T1_ = (tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)0;
T1_ = classify__pureZmath_u211(((NF) (f_p0)));
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
switch (T1_) {
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)4):
{
{
NIM_BOOL T5_;
T5_ = (NIM_BOOL)0;
T5_ = signbit__cgen_u19529(f_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
if (!T5_) goto LA6_;
result = TM__mZLUkjbotQF2WK9bQcNKBCA_17;
}
goto LA3_;
LA6_: ;
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_18;
}
LA3_: ;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)3):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_20;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)2):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_22;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)5):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_23;
}
break;
case ((tyEnum_FloatClass__gfrWEZTSUZU5OWgwK4wTYw)6):
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_24;
}
break;
default:
{
result = TM__mZLUkjbotQF2WK9bQcNKBCA_25;
addFloatRoundtrip__cgen_u19536((&result), f_p0);
if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
prepareAdd((&result), 1);
appendString((&result), TM__mZLUkjbotQF2WK9bQcNKBCA_27);
}
break;
}
}BeforeRet_: ;
return result;
}
|