[fpc-pascal] Freepascal Floating Point Issue

Sven Barth pascaldragon at googlemail.com
Thu Aug 24 14:26:06 CEST 2017


Am 24.08.2017 14:00 schrieb "James Richters" <james at productionautomation.net
>:
>
> 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
>

They probably had a custom type with operator overloads and such for that
which can be parameterized as a template with the amount of digits before
and after the comma...

Somethings like that can be implemented in FPC as well, but the
implementation would need to be done first at all ;)

Note: FPC (and Delphi) has a single fixed point type which is Currency.
AFAIK it uses four digits after the comma and 28 in front of it.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170824/9acbbbad/attachment.html>


More information about the fpc-pascal mailing list