Add floating point constants for FOUT

This commit is contained in:
Rikard Nordgren authored and FeralChild64 committed 2026-04-12 13:13:18 +02:00
1 parent b10f51345a
commit abd67c40f9
3 files changed
+31 -1

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
; This file is under the MIT license, it contains code released by Microsoft Corporation.
; See LICENSE for more information.
; Math package - constants used by FOUT
;
; This is verified to be identical to the original Microsoft implementation
;
const_NZ0999:
+PUT_CONST_NZ0999
const_NZ9999:
+PUT_CONST_NZ9999
const_NZMIL:
+PUT_CONST_NZMIL
+5
View File
@@ -58,6 +58,11 @@ std::vector<ConstEntry> GLOBAL_constants =
ConstEntry( "LOG_2", std::log(2.0) ),
ConstEntry( "INV_LOG_2", 1.0 / std::log(2.0) ),
// Constants for FOUT
ConstEntry( "NZ0999", 99999999.9 ), // Comment in MS-BASIC says 99999999.9499, but that is off by one ulp
ConstEntry( "NZ9999", 999999999.2 ), // Comment is MS-BASIC says 999999999.499, but that is off by one ulp
ConstEntry( "NZMIL", 1e9 ),
// Constants for exp approximation, taken from https://www.c64-wiki.com/wiki/POLY1
// original source is probably "Computer Approximations" by John Fraser Hart et al. (ISBN 0-88275-642-7)
ConstEntry( "POLY_EXP_1", 2.1498763701e-5 ),
+2 -1
View File
@@ -20,7 +20,7 @@ int matches[MAX_SIZE];
int phase_mask[MAX_SIZE+MAX_SIZE];
#define NUM_CHUNKS 8
#define NUM_CHUNKS 9
// Pairs of start, end memory addresses of known exact similarity with the open source Microsoft BASIC
unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
0xB391, 0xB39D,
@@ -29,6 +29,7 @@ unsigned short microsoft_basic_chunks[NUM_CHUNKS * 2] = {
0xB983, 0xB9BB,
0xBA28, 0xBCF2,
0xBD7E, 0xBD90,
0xBDB3, 0xBDC1,
0xBF11, 0xBF51,
0xBFB4, 0xBFBE,
};