<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Why not ask the CPU to do the rounding? This is what Intel offers
in volume 1 of the Intel ® 64 and IA-32 Architectures Software
Developer's Manual:<br>
</p>
<img moz-do-not-send="false"
src="cid:part1.18250560.2139650B@gmail.com" alt="" width="576"
height="176"><br>
<font size="-1">4.8.4.1<br>
Rounding Control (RC) Fields<br>
In the Intel 64 and IA-32 architectures, the rounding mode is
controlled by a 2-bit rounding-control (RC) field<br>
(Table 4-8 shows the encoding of this field). The RC field is
implemented in two different locations:<br>
•<br>
x87 FPU control register (bits 10 and 11)<br>
•<br>
The MXCSR register (bits 13 and 14)<br>
Although these two RC fields perform the same function, they
control rounding for different execution environ-<br>
ments within the processor. The RC field in the x87 FPU control
register controls rounding for computations<br>
performed with the x87 FPU instructions; the RC field in the MXCSR
register controls rounding for SIMD floating-<br>
point computations performed with the SSE/SSE2 instructions.</font><i><br>
</i><br>
Do you want more?<br>
<br>
Wolf<br>
<br>
<br>
<div class="moz-cite-prefix">On 13/06/2018 09:58, Klaus Hartnegg
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:43802aa5-bff9-c3d1-a744-b1441bcac5e8@gmx.de">Am
12.06.2018 um 23:24 schrieb Jonas Maebe:
<br>
<blockquote type="cite">On 12/06/18 23:12, Klaus Hartnegg wrote:
<br>
<blockquote type="cite">This behaviour does have advantages in
the special case of adding up many rounded numbers, but it
ruins the graphics output of my software. It should at least
be configurable. And in {$mode tp} it should behave like Turbo
Pascal, because that's what this mode is made for.
<br>
</blockquote>
<br>
The basic issue is that FPC doesn't support the 6 byte real type
used by TP in {$n-}, nor the associated behaviours such as
rounding, range/precision cut-offs etc. FPC indeed can only
support TP {$n+} mode compatibility at this time (and even that
is not always exact, as it depends on the FPU precision support
by the hardware and OS).
<br>
</blockquote>
<br>
Nevertheless it could offer an option to use the other rounding
method.
<br>
<br>
Yes, there would still be deviations in some math results, because
of the different precision. But these deviations are much smaller
than those from the other rounding method.
<br>
<br>
Klaus
<br>
_______________________________________________
<br>
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</blockquote>
<br>
</body>
</html>