Open akcansoft opened 4 years ago
I have just tried QuickBasic 4.5 and run the command PRINT VAL("5")
inside DOSBox-X 0.83.6, and this is the result I got:
I downloaded the QuickBasic 4.5 files from:
https://winworldpc.com/product/quickbasic/45
So it seems that the result here is correct (5 instead of 4.999999999999999). I tried with the default configuration (dosbox-x.exe -defaultconf
). If you have modified the DOSBox-X configuration file, you can certainly try with the default setting and see if the result is correct.
If you are using VS2019 builds and NOT using dynamic core, you may get some loss of floating point precision. VS2019 does not support the "long double" data type.
The same issue exists with a QBASIC game that checks it's own EXE file size.
Try running a MinGW build, or switch on dynamic core, or use dosbox.conf to disable the FPU emulation so that QBASIC is forced to emulate floating point in software.
I tried with the default configuration.
dosbox-x.exe -defaultconf
not modified DOSBox-X configuration file.
QuickBasic v4.5
PRINT VAL("5")
Result : 4.999999999999999
@akcansoft Can you please post a screenshot that shows the full welcome banner ("Welcome to DOSBox-X ! ..."), which will include details about the actual build you are using, e.g. Windows (VS) or MinGW, 32-bit or 64-bit, SDL1 or SDL2, etc? Thanks!
i tried new download and install
download page: https://github.com/joncampbell123/dosbox-x/releases
download file: dosbox-x-vsbuild-win-20200930224615.zip
https://github.com/joncampbell123/dosbox-x/releases/download/dosbox-x-v0.83.6/dosbox-x-vsbuild-win-20200930224615.zip
extact zip file to folder
run: folder/bin/x64/Release/dosbox-x.exe
SS:
mount c c:\dosprg
c:
cd QB45
QB
Quickbasic v4.5
PRINT VAL("5")
Result: 4.999999999999999
run: folder\x64\Release SDL2\dosbox-x.exe result is the same
next. new test: download and unzip file: dosbox-x-mingw-win64-20200930235023.zip https://github.com/joncampbell123/dosbox-x/releases/download/dosbox-x-v0.83.6/dosbox-x-mingw-win64-20200930235023.zip folder\mingw-build\mingw\dosbox-x.exe qb test result : 5 it's ok. should I use this version?
@akcansoft Yes, the last version is the MinGW build that @joncampbell123 mentioned earlier, which should work fine for this case.
Interestingly, I ran QB under DOS 6.22 running in an HD image under DOSBox-x and it gave 5 as the answer.
Is this about the initial state of Floating Point rounding mode?
I think this issue is serious enough that the either MSVC builds should have the Dynamic core selected by default, or the MinGW builds should be prioritized by the installer instead of the MSVC builds.
Either that, or figure out what's going on with the floating point conversion (bad rounding mode?), and fix the bug.
Bug is still present in newest release. Maybe make the MingW build the default?
Can you try adding:
[cpu] fpu=false
Also try using a build other than the Visual Studio based ones. Microsoft's C++ compiler does not support "long double" and maps it to plain "double".
Tried logging FPU related stuff, only saw this in the logfile:
0 FPU:FPU core: double FPU (caution: possible precision errors)
And I am aware that picking the MinGW build fixes the problem, but the MinGW build is not the preselected build when you try to install the program.
Setting "fpu = false" in CPU configuration does display the correct 5. As does using Dynamic core.
But this is about having correct behavior out of the box without needing to adjust anything.
Since MSVC appears to simply not support 80-bit floating point at all, perhaps move the 80-bit floating point code into a separate DLL that can be built using another compiler, like MinGW which does support 80-bit floating point. But this would inline very poorly. MSVC also doesn't support assembly code for the situations where you explicitly need 80-bit floating point support.
Are there programs with known issues on the Dynamic core? Making that the default could resolve the 80-bit FPU issues.
I haven't really looked into it, but when I tried the MinGW build recently, it seemed to have a problem with delayed input in the game Descent. I tried the Visual Studio build after that (built on the same code) and it didn't have the problem. So the MinGW build may have its own issues and isn't necessarily the superior option of the two.
Quickbasic calculation error on DOSBOX-X
Dosbox-X v0.83.6
PRINT VAL("5")
OUTPUT: QuickBasic v4.5 -> 4.999999999999999 Qbasic v1.1 -> 5 QBX v7.1 -> 5DOSBOX v0.74-3
PRINT VAL("5")
OUTPUT: QuickBasic v4.5 -> 5