Something encountered while testing FPC. What is your opinion on this, should this compile?
Const inf=1/0; NaN=0/0; minusinf=-1/0;
Marco van de Voort wrote:
Something encountered while testing FPC. What is your opinion on this, should this compile?
Const inf=1/0; NaN=0/0; minusinf=-1/0;
I don't think so. Both BP (your paragon) and GPC don't. The standard, if you care, does not seem to explicitly mention this case, but since it refers to the usual mathematical rules, I understand that it doesn't allow it, either.
If you want access to these special values, you might rather want to supply them as predefined constants (like MinReal, MaxReal and EpsReal) -- though there may arise problems on non-IEEE FP systems (if you support any) which may not even know those values ...
Frank
Marco van de Voort wrote:
Something encountered while testing FPC. What is your opinion on this, should this compile?
Const inf=1/0; NaN=0/0; minusinf=-1/0;
I don't think so. Both BP (your paragon) and GPC don't. The standard, if you care, does not seem to explicitly mention this case, but since it refers to the usual mathematical rules, I understand that it doesn't allow it, either.
We also have a Delphi mode, which is getting increasingly important This is valid Delphi code unfortunately. I also thought it is ugly, specially from a mathematical viewpoint. I said that on the Delphi list, and it turns out to be specified in the IEEE standard (at least according to them)
If you want access to these special values, you might rather want to supply them as predefined constants (like MinReal, MaxReal and EpsReal) -- though there may arise problems on non-IEEE FP systems (if you support any) which may not even know those values ...
I don't know how many types exist under IEEE. Afaik there are larger types? (doesn't the Itanium have 128 bit FP types?)
Marco van de Voort wrote:
Marco van de Voort wrote:
Something encountered while testing FPC. What is your opinion on this, should this compile?
Const inf=1/0; NaN=0/0; minusinf=-1/0;
I don't think so. Both BP (your paragon) and GPC don't. The standard, if you care, does not seem to explicitly mention this case, but since it refers to the usual mathematical rules, I understand that it doesn't allow it, either.
We also have a Delphi mode, which is getting increasingly important This is valid Delphi code unfortunately. I also thought it is ugly, specially from a mathematical viewpoint. I said that on the Delphi list, and it turns out to be specified in the IEEE standard (at least according to them)
No mention in ISO10206. They may be referring to the IEEE FP standard, which is not binding on the language, but convenient.
It would do no harm to have them as predefined constants at level 0 - this never interferes with user definitions. Of course, what _is_ that constant? If the real processor is IEEE then there is a hex pattern for them. Comparisons against them must follow special rules.
Marco van de Voort wrote:
We also have a Delphi mode, which is getting increasingly important This is valid Delphi code unfortunately. I also thought it is ugly, specially from a mathematical viewpoint. I said that on the Delphi list, and it turns out to be specified in the IEEE standard (at least according to them)
Might be, but AFAIK Pascal is not based on IEEE. But interesting to see that apparently they take the IDEE standard more importantly than the Pascal standard. :-(
As I said, you (or Borland as well) might get problems with this if you support (now or in the future) any non-IEEE platform unless you want to emulate the complete FP then ...
If you want access to these special values, you might rather want to supply them as predefined constants (like MinReal, MaxReal and EpsReal) -- though there may arise problems on non-IEEE FP systems (if you support any) which may not even know those values ...
I don't know how many types exist under IEEE. Afaik there are larger types? (doesn't the Itanium have 128 bit FP types?)
I think so, but how is this related?
Frank
We also have a Delphi mode, which is getting increasingly important This is valid Delphi code unfortunately. I also thought it is ugly, specially from a mathematical viewpoint. I said that on the Delphi list, and it turns out to be specified in the IEEE standard (at least according to them)
Might be, but AFAIK Pascal is not based on IEEE. But interesting to see that apparently they take the IDEE standard more importantly than the Pascal standard. :-(
As I said, you (or Borland as well) might get problems with this if you support (now or in the future) any non-IEEE platform unless you want to emulate the complete FP then ...
For those platforms you need special handling anyhow, since the predefined constants also won't work.
There is a difference of course, handling it in the processor dependant part of the compiler, or in the processor dependant part of the library.
If you want access to these special values, you might rather want to supply them as predefined constants (like MinReal, MaxReal and EpsReal) -- though there may arise problems on non-IEEE FP systems (if you support any) which may not even know those values ...
I don't know how many types exist under IEEE. Afaik there are larger types? (doesn't the Itanium have 128 bit FP types?)
I think so, but how is this related?
How many constants you have to predefine for IEEE support.
Marco van de Voort wrote:
We also have a Delphi mode, which is getting increasingly important This is valid Delphi code unfortunately. I also thought it is ugly, specially from a mathematical viewpoint. I said that on the Delphi list, and it turns out to be specified in the IEEE standard (at least according to them)
Might be, but AFAIK Pascal is not based on IEEE. But interesting to see that apparently they take the IDEE standard more importantly than the Pascal standard. :-(
As I said, you (or Borland as well) might get problems with this if you support (now or in the future) any non-IEEE platform unless you want to emulate the complete FP then ...
For those platforms you need special handling anyhow, since the predefined constants also won't work.
That's what I meant. Any way of supporting them will be at best rather difficult and inefficient to support on these.
If you want access to these special values, you might rather want to supply them as predefined constants (like MinReal, MaxReal and EpsReal) -- though there may arise problems on non-IEEE FP systems (if you support any) which may not even know those values ...
I don't know how many types exist under IEEE. Afaik there are larger types? (doesn't the Itanium have 128 bit FP types?)
I think so, but how is this related?
How many constants you have to predefine for IEEE support.
I don't understand this question. IEEE defines some FP formats which imply certain constants, of course.
The predefined constants I was referring to are these of Pascal (not of Borland Pascal, though). I think there are only these 3. So for IEEE they'll have certain values, but since Pascal is not bound to IEEE arithmetic, they can have any other (reasonable) values, and the Pascal programmer can check them.
Frank