Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Assigning real to integer

35 views
Skip to first unread message

john

unread,
Dec 23, 2007, 6:52:25 PM12/23/07
to
Is there any way to assign a real variable to an integer variable?


Thanks.

Chris Burrows

unread,
Dec 23, 2007, 7:44:27 PM12/23/07
to
"john" <jo...@no.spam> wrote in message
news:fkmsbp$qsp$1...@ulysses.noc.ntua.gr...

> Is there any way to assign a real variable to an integer variable?
>

Look for the definitions of the standard functions 'trunc' or 'round' in the
documentation for the Pascal implementation that you are using.

I recommend that if you wish to learn how to program in Pascal that you
acquire, and read, a copy of the 'Pascal User Manual and Report' by Kathleen
Jensen and Niklaus Wirth if you have not already done so.

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/gpcp


CBFalconer

unread,
Dec 23, 2007, 8:29:16 PM12/23/07
to
john wrote:
>
> Is there any way to assign a real variable to an integer variable?

>From ISO10206:

6.7.6.3 Transfer functions

trunc(x)

From the expression x that shall be of real-type, this function
shall return a result of integer-type. The value of trunc(x)
shall be such that if x is positive or zero, then 0 <= x -
trunc(x)
< 1; otherwise -1 < x <= x - trunc(x). It shall be an error if
such
a value does not exist.

Examples:
trunc(3.5) {yields 3}
trunc(-3.5) {yields -3}

round(x)

From the expression x that shall be of real-type, this function
shall return a result of integer-type. If x is positive or zero,
round(x) shall be equivalent to trunc(x+0.5); otherwise, round(x)
shall be equivalent to trunc(x-0.5) It shall be an error if such
a value does not exist.

--
Merry Christmas, Happy Hanukah, Happy New Year
Joyeux Noel, Bonne Annee.
Chuck F (cbfalconer at maineline dot net)
<http://cbfalconer.home.att.net>


--
Posted via a free Usenet account from http://www.teranews.com

0 new messages