Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: How to remove the "0." from "0. + 1.41774i"
Replies: 8   Last Post: Jun 23, 2013 10:50 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Simons, F.H.

Posts: 107
Registered: 12/7/04
Re: How to remove the "0." from "0. + 1.41774i" [Revised]
Posted: Jun 23, 2013 10:50 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Want you want to do can be achieved by changing the way Mathematica
prints complex numbers, for example in the following way:

In[1]:= 0.+4.23I
4.23+0. I
3.5+4.2 I

Out[1]= 0. +4.23 I
Out[2]= 4.23 +0. I
Out[3]= 3.5 +4.2 I

In[4]:= MakeBoxes[Complex[a_ /; Chop[a]==0., b_] , StandardForm] :=
RowBox[{MakeBoxes[b, StandardForm]," ", MakeBoxes[I,StandardForm]}];

MakeBoxes[Complex[a_ , b_/;Chop[b]==0] , StandardForm] := MakeBoxes[a,
StandardForm];

In[6]:= 0.+4.23I
4.23+0. I
3.5+4.2 I

Out[6]= 4.23 I
Out[7]= 4.23
Out[8]= 3.5 +4.2 I

Be careful; there might be side effects.

Fred Simons
Eindhoven University of Technology




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.