MathGroup Archive 2013

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

Search the Archive

Re: How to remove the "0." from "0. + 1.41774i" [Revised]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg131279] Re: How to remove the "0." from "0. + 1.41774i" [Revised]
  • From: Fred Simons <f.h.simons at tue.nl>
  • Date: Sun, 23 Jun 2013 22:56:58 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <kpucst$9f7$1@smc.vnet.net> <20130621095850.7C9AB69ED@smc.vnet.net> <20130622073208.4E9F469E7@smc.vnet.net>

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



  • Prev by Date: Re: vertices of a rectangle
  • Next by Date: Position[] bug or feature ?
  • Previous by thread: Re: How to remove the "0." from "0. + 1.41774i" [Revised]
  • Next by thread: Duplex Printing from button inside DialogNotebook on Mac