Re: Conversion of Real to Integer
- To: mathgroup at smc.vnet.net
- Subject: [mg3070] Re: Conversion of Real to Integer
- From: Robert Knapp <rknapp>
- Date: Tue, 30 Jan 1996 02:24:10 -0500
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup 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. The one exception is 0, since N=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 ==== [MESSAGE SEPARATOR] ====