[comp.lang.modula2] integer to longreal

cs419110@pc.usl.edu (Durand Barry Paul) (10/15/90)

Does anyone out there know how to convert an integer to a longreal
in modula2 (obviously).

Thanks in advance....

Barry
-- 
-----------------------------------------------------------------------------
Barry Durand  cs419110@pc.usl.edu     ....!samsung!rex!rouge!pc!cs419110
University of Southwestern Louisiana (USL)
------------------------------------------------------------------------------

bpd5428@rouge.usl.edu (Durand Barry P) (10/16/90)

Does anyone out there know how to convert an integer to a longreal 
(in modula2 ofcourse).

Thanks,

GRANGERG@VTVM1.BITNET (Greg Granger) (10/16/90)

On Mon, 15 Oct 90 20:42:34 GMT Durand Barry P said:
>Does anyone out there know how to convert an integer to a longreal
>(in modula2 ofcourse).
>
>Thanks,

Well depends, which Modula 2 are you using?  Try looking at the
VAL procedure.

In TopSpeed it would be something like this:
      i: INTEGER;
      x: LONGREAL;
      ....
      x:= VAL(LONGREAL, i);

Of course some other version may (prob'ly will) do it differently.
You might also check the FLOAT procedure (in the "standard" (3th ed)
it's for converting CARDINAL to REAL).

Greg

cs419110@PC.USL.EDU (Durand Barry Paul) (10/17/90)

Greg,

Thanks for the information on the integer to longreal conversion in
modula2.  Not sure if it worked yet (am getting this info for a friend)
but I will tell you if it did.

Thanks,

Barry
cs419110@pc.usl.edu(definitly works)
bpd5428@rouge.usl.edu(having problems with this account)

bartonr@eecs.cs.pdx.edu (Robert L Barton) (10/17/90)

GRANGERG@VTVM1.BITNET (Greg Granger) writes:

> In TopSpeed it would be something like this:
>       i: INTEGER;
>       x: LONGREAL;
>       ....
>       x:= VAL(LONGREAL, i);

  I would hope this doesn't work, since VAL() is meaningless for LONGREALs.
And ISO M-2 may do away with LONGREALs anyway.

--------------------------------------------------------------------------------
Robert L Barton                                          bartonr@eecs.cs.pdx.edu
Concert Concessions Corporation,      a division of       Winterland Productions

GRANGERG@VTVM1.BITNET (Greg Granger) (10/18/90)

On Wed, 17 Oct 90 05:02:47 GMT Robert L Barton said:
>>       x:= VAL(LONGREAL, i);
>
>  I would hope this doesn't work, since VAL() is meaningless for LONGREALs.
>And ISO M-2 may do away with LONGREALs anyway.
>
>-----------------------------------------------------------------------

Well sorry to rain on your parade, but in TopSpeed that is exactly how
it works.  As to standards, well sometimes what works is more useful
than what is standard.  I found no reference to LONGREALs in N Wirth's
3th ed of PIM2 and I don't know much about the ISO M2 work (cept it's
not finished).  If it were up to me I would do things differently,
but it's not.... (I really don't care for all that type casting and
explict conversion, wish someone would expand "the standard" (what
ever it is) to include operator overloading then I overload '+'
to add int's to card's or card's to real's or ... apples to oranges
<grin>)

Greg

Markus.Maeder@p2.f807.n302.z2.fidonet.org (Markus Maeder) (10/20/90)

Hello Durand..

 DB> Newsgroups: comp.lang.modula2
 DB>
 DB> Does anyone out there know how to convert an integer to a longreal
 DB> in modula2 (obviously).
 DB>

It's very simple:

VAR i:INTEGER;
    l:LONGREAL;
...
    i:=10;    (* e.g. *)
    l:=LONGREAL(i);
    ^^^^^^^^^^^^^^^
...........



Tschss,
   Markus Maeder


--  
uucp: uunet!m2xenix!puddle!2!302!807.2!Markus.Maeder
Internet: Markus.Maeder@p2.f807.n302.z2.fidonet.org