[fpc-pascal] Freepascal Floating Point Issue
Ched
charles.edouard.des.vastes.vignes at gmail.com
Thu Aug 24 23:45:47 CEST 2017
And under "modern" Windows, the extended type, which is fully supported by the FPU, is *degraded* to
double. So, I can't do high precision computation with fpc even if the native hardware permits such
computations. I'm glued to XP as the full capabilities of the FPU were on the hands of programmers, years
ago.
Cheers, Ched'
Le 24.08.2017 à 21:31, Bernd Oppolzer a écrit :
> Am 24.08.2017 um 14:00 schrieb James Richters:
>>
>> 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
>>
>> 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
>>
>> James
>>
>>
>
> IBM mainframes have decimal data types involving 31 decimal digits
> (maximum); the numbers of digits left and right of the decimal point
> may be chosen freely. The types are all compatible and promoted to
> floating point, when necessary. The mainframe languages, like PL/1
> and COBOL, support them natively, and mainframe C, too:
>
> int x, y;
> decimal (15,2) amt;
> ...
>
> These decimal data types are supported by the hardware (by
> machine instructions). This was an optional feature in the 1960s,
> but the modern machines of today all support it.
>
> The decimal data is implemented as BCD data; hex digits are
> decimal digits, and a sign half byte is added, that makes 16 bytes
> for 31 digits. If shorter numbers are needed, less bytes are allocated
> (all lengths from 1 to 16 are supported). All decimal fields have
> odd numbers of digits.
>
> I am thinking about adding support for decimal data in one of the
> next versions of my Stanford Pascal compiler, which targets this
> platform, as well as Windows, Linux, macOS etc.; of course, this
> decimal format will need to be emulated on the non-mainframe
> platforms.
>
> For some years now, the mainframe also supports floating point
> data based on a decimal representation. But I don't have experience
> with this so far. Some compilers support this (PL/1).
>
> Kind regards
>
> Bernd
>
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list