6-Apr-00 07:53 you wrote:
J. David Bryan wrote:
On 5 Apr 2000, at 18:30, Peter Gerwinski wrote:
What does GCC do on the same platforms?
("mod" is "%" in C.)
Unfortunately, that won't help define what Pascal should do (I think that is what you are implying here -- apologies if it is not). The semantics of mod varies among languages, so deciding what C does isn't applicable.
What I'd like to have checked is whether GNU C's "mod" operation produces different results on different platforms.
It DOES.
If so, we have detected a bug in the backend, otherwise in the frontend.
It's NOT bug. It's feature. Different processors have different ideas about what (6 mod -90) means. Beaing "high-level assebler" C does NOT define what "%" will do if negative numbers involved so most efficient implementation can be used. In case of iX86 processor will return (6/-90)==0, (6%-90)==6, (100/-90)==-1, (100%-90)==10, etc (basically: do division with absolute values, then add sign to make equation x==(x div y)*y+(x mod y) correct).
Of course, this must be fixed and changed to something Pascalish.
The question is "what is something pascalish" ? BP, Delphi and so on are all usuing the same low-lovel idiv as GCC, for example ... And produce the same result, of course... Unlike gpc BTW (gcc 2.95.2 will return the same "not very mathematically correct" values as BP/Delphi and iX86's idiv while gpc 19991030 based on gcc 2.95.2 will return "more mathematically correct" thing by adding few checks after idiv... hmm...).