Przeglądaj źródła

reduce float print precision, remove vcc fpu workaround

Nicolas Cannasse 9 lat temu
rodzic
commit
c1506d8d6e
1 zmienionych plików z 3 dodań i 14 usunięć
  1. 3 14
      src/std/string.c

+ 3 - 14
src/std/string.c

@@ -35,21 +35,10 @@ HL_PRIM vbyte *hl_ftos( double d, int *len ) {
 		*len = 3;
 		*len = 3;
 		return hl_copy_bytes((vbyte*)USTR("NaN"),8);
 		return hl_copy_bytes((vbyte*)USTR("NaN"),8);
 	}
 	}
-#	if defined(HL_VCC) && !defined(HL_64)
-	/*
-		For some unknown reason, we reach here with some conditional bits set in FPU status,
-		leading to a crash in sprintf (reproducible with -1.0 value).
-		Let's then make sure to save/restore FPU state
-	*/
-	__declspec(align(16)) char fpu[512];
-	_fxsave(fpu);
-	__asm { finit };
-#	endif
-	k = (int)usprintf(tmp,24,USTR("%.16g"),d); // don't use the last digit (eg 5.1 = 5.09999..996)
+	// don't use the last digit (eg 5.1 = 5.09999..996)
+	// also cut one more digit for some numbers (eg 86.57 and 85.18) <- to fix since we lose one PI digit
+	k = (int)usprintf(tmp,24,USTR("%.15g"),d);
 	*len = k;
 	*len = k;
-#	if defined(HL_VCC) && !defined(HL_64)
-	_fxrstor(fpu);
-#	endif
 	return hl_copy_bytes((vbyte*)tmp,(k + 1) << 1);
 	return hl_copy_bytes((vbyte*)tmp,(k + 1) << 1);
 }
 }