On 2/4/2024 12:32 PM, James Richters via fpc-pascal wrote:

>> 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.

Sorry, but that doesn't make any sense. If you just add the .0, you specify a floating point value, ANY floating point value. This is kind of obvious in a programming language that has only one type of floating point value (yes, they are less common these days as they used to be in the "days of old"). But you did not specify WHICH type of the possibly floating point values you are expecting, and there are three different ones (single, double, extended). What happens when you assume an integer/word/longint by omitting the decimal fraction, that's a different discussion.

But I would expect that you you explicitly use a typecast as in "extended (1440.0)" that the compiler is using an extended floating point calculation at that point. Specifying the resulting variable to be a specific type is IMHO not implying that ALL calculations of a whole expression are performed in that variable's type. If the compiler would ignore an explicit type cast of a constant, THEN I would call this a bug.


Ralf

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to