Silverfrost Forums

Welcome to our forums

A Fortran 90/95 Equivalent of Pascal

21 Feb 2018 5:37 #21492

Dear Silverfrost Community: Do any of you know of a function (intrinsic or otherwise) that returns the same argument as that of the DIV intrinsic function of Pascal? Thank you. 😃

21 Feb 2018 7:12 #21493

Did you mean 'result' rather than 'argument'?

No function is needed. If a and b are of type INTEGER, a/b gives you the integer quotient. If either is of some other type, and if appropriate, use INT(a)/INT(b) .

21 Feb 2018 9:27 #21494

Dear mecej4: I meant 'result' rather than 'argument.' Thank you. 😃

2 Mar 2018 11:50 #21548

Quoted from John-Silver ... or INT(AINT(A/B)) maybe , for any A,B integer or real ? In Pascal, the two operands of the div operator must be one of the integer types. The result (the quotient) is also of integer type. The Fortran intrinsic AINT must be given a real argument, and I see no reason to use it for the purpose stated in the first post. For many combinations of values, such as A = 65537 and B = 4097, INT(AINT(A/B)) gives the wrong result. In this case, it gives 16, whereas the actual quotient is 15.

5 Mar 2018 10:54 #21570

That looks reasonable and appropriate -- for a CDC 6xxx machine. The 6XXX CPUs did not have instructions for general integer arithmetic!

Please login to reply.