MathGroup Archive 2003

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

Search the Archive

RE: Decimal point in printed numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41590] RE: [mg41577] Decimal point in printed numbers
  • From: "Florian Jaccard" <jaccardf at eicn.ch>
  • Date: Wed, 28 May 2003 04:57:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello !

For the fun, I tried to imagin a solution to your problem.
Example : let

nombres = {1., 2.1, 3., 4.5, 5.5, 6}

be the labels for axes in a plot.

In[43]:=
fract=Rationalize[nombres];

In[44]:=
pos=Position[fract,Rational[_,_]];

In[45]:=
abscisses = Table[If[MemberQ[pos, {i}], nombres[[i]],
     fract[[i]]], {i, 1, Length[nombres]}];

In[46]:=
Plot[Sin[x],{x,0,7},Ticks->{abscisses,Automatic}];

I'm sure there are better ways... but it works !

Meilleures salutations

Florian Jaccard


-----Message d'origine-----
De : Jan Rychter [mailto:jan at rychter.com]
Envoyé : mar., 27. mai 2003 11:25
À : mathgroup at smc.vnet.net
Objet : [mg41577] Decimal point in printed numbers


I'm generating labels for axes in a plot. If I numericalize (N[]) them,
I get a decimal point after each number, even if there is no fractional
part. If I don't I risk getting rationals (1/2). What is the preferred
solution?

I guess I could either convert everything to reals (using N[]) and
change the printed representation (but I couldn't find out how to get
rid of the decimal point reading the manuals), or try to stick with
precise numbers and only convert if fractions result. Is there a way to
do that?

--J.



  • Prev by Date: multiple of sum of fraction by common denominator keeps fractions in result
  • Next by Date: integration of rational functions with parameter; simplification. Limit
  • Previous by thread: Re: Decimal point in printed numbers
  • Next by thread: N[ ] function problem