mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-05-23 06:34:18 -04:00
Link MSL_C/ansi_fp
This commit is contained in:
+1
-1
@@ -820,7 +820,7 @@ config.libs = [
|
||||
"objects": [
|
||||
Object(Matching, "MSL_C.PPCEABI.bare.H/abort_exit.c"),
|
||||
Object(Matching, "MSL_C.PPCEABI.bare.H/ansi_files.c"),
|
||||
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_fp.c"),
|
||||
Object(Matching, "MSL_C.PPCEABI.bare.H/ansi_fp.c"),
|
||||
Object(NonMatching, "MSL_C.PPCEABI.bare.H/arith.c"),
|
||||
Object(Matching, "MSL_C.PPCEABI.bare.H/buffer_io.c"),
|
||||
Object(Matching, "MSL_C.PPCEABI.bare.H/ctype.c"),
|
||||
|
||||
@@ -22,7 +22,7 @@ typedef struct decform {
|
||||
|
||||
void __num2dec(const decform*, double, decimal*);
|
||||
void __num2dec_internal(decimal*, double);
|
||||
void __two_exp(decimal*, long);
|
||||
void __two_exp(decimal*, short);
|
||||
void __str2dec(decimal*, const char*, short);
|
||||
void __timesdec(decimal*, const decimal*, const decimal*);
|
||||
void __ull2dec(decimal*, unsigned long long);
|
||||
|
||||
@@ -174,8 +174,6 @@ void __str2dec(decimal* d, const char* s, short exp) {
|
||||
if (*s != 0) {
|
||||
if (*s < 5)
|
||||
return;
|
||||
if (*s > 5)
|
||||
goto round;
|
||||
|
||||
{
|
||||
const char* p = s + 1;
|
||||
@@ -193,7 +191,7 @@ void __str2dec(decimal* d, const char* s, short exp) {
|
||||
}
|
||||
}
|
||||
|
||||
void __two_exp(decimal* result, long exp) {
|
||||
void __two_exp(decimal* result, short exp) {
|
||||
switch (exp) {
|
||||
case -64:
|
||||
__str2dec(result, "542101086242752217003726400434970855712890625", -20);
|
||||
@@ -269,11 +267,14 @@ void __two_exp(decimal* result, long exp) {
|
||||
if (exp & 1) {
|
||||
temp = *result;
|
||||
if (exp > 0) {
|
||||
__str2dec(&x2, "2", 0);
|
||||
decimal temp2;
|
||||
__str2dec(&temp2, "2", 0);
|
||||
__timesdec(result, &temp, &temp2);
|
||||
} else {
|
||||
__str2dec(&x2, "5", -1);
|
||||
decimal temp2;
|
||||
__str2dec(&temp2, "5", -1);
|
||||
__timesdec(result, &temp, &temp2);
|
||||
}
|
||||
__timesdec(result, &temp, &x2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,7 +305,7 @@ void __num2dec_internal(decimal* d, double x) {
|
||||
{
|
||||
int exp;
|
||||
double frac = frexp(x, &exp);
|
||||
long num_bits_extract = DBL_MANT_DIG - __count_trailing_zero(frac);
|
||||
short num_bits_extract = DBL_MANT_DIG - __count_trailing_zero(frac);
|
||||
double integer;
|
||||
decimal int_d, pow2_d;
|
||||
|
||||
@@ -316,6 +317,42 @@ void __num2dec_internal(decimal* d, double x) {
|
||||
}
|
||||
}
|
||||
|
||||
static int __must_round(const decimal* d, int digits){
|
||||
//regswap fun here
|
||||
unsigned char const* i = d->sig.text + digits;
|
||||
|
||||
if (*i > 5) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (*i < 5) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i++; i < d->sig.text + d->sig.length; i++){
|
||||
if (*i != 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (d->sig.text[digits - 1] & 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void __rounddec(decimal* d, int digits){
|
||||
if (digits > 0 && digits < d->sig.length) {
|
||||
int unkBool = __must_round(d,digits);
|
||||
d->sig.length = digits;
|
||||
|
||||
if (unkBool >= 0) {
|
||||
__dorounddecup(d, digits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __num2dec(const decform* form, double x, decimal* d) {
|
||||
short digits = form->digits;
|
||||
int i;
|
||||
@@ -341,3 +378,11 @@ void __num2dec(const decform* form, double x, decimal* d) {
|
||||
d->sig.text[i] += '0';
|
||||
}
|
||||
}
|
||||
|
||||
// @unused
|
||||
double __dec2num(const decimal* d)
|
||||
{
|
||||
decimal max;
|
||||
|
||||
__str2dec(&max, "179769313486231580793729011405303420", 308);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user