MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Conversion of Real to Integer

  • Subject: [mg3070] Re: Conversion of Real to Integer
  • From: rknapp (Robert Knapp)
  • Date: 30 Jan 1996 04:28:24 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at wri.com

DR JOHN C ERB wrote:
> 
> In mathematica, how can one emulate the fortran real to integer
> conversion functions INT ( ) and
> NINT ()?  An example being: INT(3.6) --> 3 and NINT(3.6) --> 4.  Also,
>  how does one convert from integer to real?  Thank you.

The fortran INT is equivalent to Floor

The fortran NINT is equivalent to Round

To convert from integer to real, use N[].  For example, N[3] = 3.
The one exception is 0, since N[0]=0.  This is because Mathematica
treats simplification with an exact zero differently than with an
inexact 0 (0.)

If you use combinations of integers and reals in an expression,
generally the integers will be converted automatically to reals.
-- 
Rob Knapp
Wolfram Research, Inc.

http://www.wri.com/~rknapp


  • Prev by Date: Re: 3d graph
  • Next by Date: Neuronal Modeling
  • Previous by thread: Re: Conversion of Real to Integer
  • Next by thread: Re: Conversion of Real to Integer