<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Am 24.08.2017 um 14:00 schrieb James Richters:<br>
<blockquote type="cite"
cite="mid:075e01d31cd0$8cc851b0$a658f510$@productionautomation.net">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Thanks everyone for the explanation and
solutions. I can work around it well enough now that I
understand what’s happening, but I’m still curious if there is
a way to define fixed point variables? In a C++ Project I was
helping with recently, they had a way of defining a variable
as having 2 places before the decimal and 30 places after?
Since the decimal could never move (float) It ended up being
much better defined. It’s like always moving the decimal
over 30 places to the right, using integer math, then moving
it back. I’m not sure if this was something the compiler did,
or if maybe they had their own functions to do this… I had a
difficult time following how things worked, but I do remember
the fixed point variables. Anyway I thought I would just ask
the question in case there is a way to define this in
FreePascal<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">It seems to me that if you know you never
need more than a fixed number of places before and after the
decimal, then moving the decimal over the maximum number of
places, performing integer math, which would round to the
nearest integer(and cut off the useless garbage), then moving
the decimal back would mean a fixed amount of precision with
the benefit that one could do things like exact conditionals
and get the expected result<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">James<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<br>
</div>
</blockquote>
<br>
IBM mainframes have decimal data types involving 31 decimal digits <br>
(maximum); the numbers of digits left and right of the decimal point
<br>
may be chosen freely. The types are all compatible and promoted to <br>
floating point, when necessary. The mainframe languages, like PL/1 <br>
and COBOL, support them natively, and mainframe C, too: <br>
<br>
int x, y; <br>
decimal (15,2) amt; <br>
...<br>
<br>
These decimal data types are supported by the hardware (by <br>
machine instructions). This was an optional feature in the 1960s, <br>
but the modern machines of today all support it. <br>
<br>
The decimal data is implemented as BCD data; hex digits are <br>
decimal digits, and a sign half byte is added, that makes 16 bytes <br>
for 31 digits. If shorter numbers are needed, less bytes are
allocated<br>
(all lengths from 1 to 16 are supported). All decimal fields have<br>
odd numbers of digits. <br>
<br>
I am thinking about adding support for decimal data in one of the <br>
next versions of my Stanford Pascal compiler, which targets this <br>
platform, as well as Windows, Linux, macOS etc.; of course, this <br>
decimal format will need to be emulated on the non-mainframe <br>
platforms. <br>
<br>
For some years now, the mainframe also supports floating point <br>
data based on a decimal representation. But I don't have experience
<br>
with this so far. Some compilers support this (PL/1). <br>
<br>
Kind regards<br>
<br>
Bernd <br>
<br>
</body>
</html>