Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a preferred way of converting an Integer to a Real?

What I'm using at the moment is x + 0.0.

share|improve this question
N is what I use. – Michael E2 Oct 15 '13 at 19:20
@MichaelE2 your chance to post a canonical answer using one character ;-) – Yves Klett Oct 16 '13 at 5:24
Although the answer is trivial, there is no one-hit wonder on google or in the documentation. The first immediately useful hit is, which is already running under "legacy", so I would vote against closure as long as @MichaelE2 posts his comment as answer. – Yves Klett Oct 16 '13 at 7:57
@yvesklett I was about to vote to close, but you're right, unfortunately. I have been trying to find an answer to this question as if I were a newbie. There just doesnt seem to be an easy and intuitive way a new user could arrive at the answer, at least not from the online documentation. – Sjoerd C. de Vries Oct 16 '13 at 9:33
@SjoerdC.deVries my first reflex was also to close (as in quite a few cases these last days). It may be a duplicate, but in fact this title question and the straightforward answer may be even more useful for newbies. – Yves Klett Oct 16 '13 at 11:29
up vote 9 down vote accepted


A one-character answer is disallowed by SE, so I will expand. N is mostly what I use. If I have an expression like $2 x + 3$, I sometimes write it 2. x + 3. in Mathematica; then if x is numeric, whether it happens to be an Integer or not, the expression will always be Real or Complex.

share|improve this answer
Indeed, the last part of the statement is always true, my bad. Well... actually, if x is something completely different..... :) – István Zachar Oct 16 '13 at 11:17
Head /@ {23, 23*1, 23/1, 23 + 0, 23., 23*1., 23/1., 23 + 0.}

{Integer, Integer, Integer, Integer, Real, Real, Real, Real}

share|improve this answer

This also

{Head[1], Head[1 // N]}

{Integer, Real}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.