Ivan Levashew
2009-05-05 05:34:46 UTC
Hello!
I can't get floating point operations working. Try running this in your
version of Turbo (Borland) Pascal:
{$N+}
uses CRT;
type Float = Real;
var X, Y, Z : Float;
function TestOK : Boolean;
var R : String;
begin
X := 2.0;
Y := 5.0;
Z := X / Y;
Str(Z : 0 : 3, R);
TestOK := R = '0.400';
end;
var i : Integer;
begin
i := 0;
while TestOK do
begin
i := i + 1;
if i >= 1000 then begin Write('.'); i := 0; end;
if KeyPressed then Break;
end;
WriteLn('Iterations: ', i);
end.
The problem might appear after you have run this program from IDE
several times. It doesn't appear when program is being launched from
command line. It doesn't appear on the first launch.
During the first several runs everything is OK: 2.0 / 5.0 = 0.400
But then floating point goes wild. 2.0 / 5.0 = 5.00, then NaNs, then
another stupid values. I have to keep {$N-,$E+} mode because of this. I
tried various versions of BP, the problem seems to be everywhere.
But I can't remember ever having such a problem on a real DOS
environment. So I guess this is DOSBox specific problem.
Do you know a cure against it? {$N-,E+} doesn't count. Neither FPC.
I can't get floating point operations working. Try running this in your
version of Turbo (Borland) Pascal:
{$N+}
uses CRT;
type Float = Real;
var X, Y, Z : Float;
function TestOK : Boolean;
var R : String;
begin
X := 2.0;
Y := 5.0;
Z := X / Y;
Str(Z : 0 : 3, R);
TestOK := R = '0.400';
end;
var i : Integer;
begin
i := 0;
while TestOK do
begin
i := i + 1;
if i >= 1000 then begin Write('.'); i := 0; end;
if KeyPressed then Break;
end;
WriteLn('Iterations: ', i);
end.
The problem might appear after you have run this program from IDE
several times. It doesn't appear when program is being launched from
command line. It doesn't appear on the first launch.
During the first several runs everything is OK: 2.0 / 5.0 = 0.400
But then floating point goes wild. 2.0 / 5.0 = 5.00, then NaNs, then
another stupid values. I have to keep {$N-,$E+} mode because of this. I
tried various versions of BP, the problem seems to be everywhere.
But I can't remember ever having such a problem on a real DOS
environment. So I guess this is DOSBox specific problem.
Do you know a cure against it? {$N-,E+} doesn't count. Neither FPC.
--
If you want to get to the top, you have to start at the bottom
If you want to get to the top, you have to start at the bottom