[fpc-pascal] Floating point question

James Richters james.richters at productionautomation.net
Sun Feb 4 21:32:28 CET 2024


>> Not specifying in a program, specially in a strict programming language like Pascal, will always result in implementation depending 
>> variations/assumptions.
 
The problem is, I feel that I DID specify what should be by declaring my variable as Extended.   And Apparently FPC agrees with me, because it DOES work the way I expect, except if I put a .0 in my constant terms.   This is all just a bug if you put .0 after any integers in an expression.  I just put a better example that shows how it works correctly except if you put a .0

Strangely, upon discovering this, the solution is opposite what I thought it should be.  If all the terms of an expression were reduced to the lowest precision possible without loosing data, then my 1440.0 would be reduced from a float to a word, and then the entire problem would have went away, because when I put in 1440 without the .0, there is no problem.    The .0 is apparently defining it to be a floating point and the smallest floating point is a single… but that’s not the smallest data structure, the smallest data structure that can be used is a word and that would have solved it. 
 
James
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20240204/13a5ebc5/attachment-0001.htm>


More information about the fpc-pascal mailing list