forums.silverfrost.com
Welcome to the Silverfrost forums

Author Message
SaintMichael57

Joined: 28 Nov 2016
Posts: 14

 Posted: Wed Feb 21, 2018 6:37 pm    Post subject: A Fortran 90/95 Equivalent of Pascal 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.
mecej4

Joined: 31 Oct 2006
Posts: 1372

 Posted: Wed Feb 21, 2018 8:12 pm    Post subject: 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) .
SaintMichael57

Joined: 28 Nov 2016
Posts: 14

 Posted: Wed Feb 21, 2018 10:27 pm    Post subject: A reply Dear mecej4: I meant "result" rather than "argument." Thank you.
John-Silver

Joined: 30 Jul 2013
Posts: 1400
Location: Aerospace Valley

 Posted: Fri Mar 02, 2018 5:34 am    Post subject: ... or INT(AINT(A/B) maybe , for any A,B integer or real ?_________________''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... "
mecej4

Joined: 31 Oct 2006
Posts: 1372

Posted: Fri Mar 02, 2018 12:50 pm    Post subject: Re:

 John-Silver wrote: ... 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.
John-Silver

Joined: 30 Jul 2013
Posts: 1400
Location: Aerospace Valley

 Posted: Mon Mar 05, 2018 10:35 pm    Post subject: so what about INT(AINT(FLOAT(A)/FLOAT(B))) then ?_________________''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... "
mecej4

Joined: 31 Oct 2006
Posts: 1372

 Posted: Mon Mar 05, 2018 11:54 pm    Post subject: That looks reasonable and appropriate -- for a CDC 6xxx machine. The 6XXX CPUs did not have instructions for general integer arithmetic!
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT + 1 Hour Page 1 of 1

 Jump to: Select a forum Admin----------------Announcements FTN95----------------GeneralKBaseSupportSuggestionsClearWin+Plato64-bit FTN77----------------Support
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group