# Why doesn't the Round function work on decimals and how to fix it or work around it [duplicate]

I'm trying to specify yaxis tick labels from 0 to 1.0 in steps of 0.1. This is what I get:

ygrids=Range[0,1.0,0.1];
0.,0.1,0.2,0.30000000000000004,0.4,0.5,0.6000000000000001,0.7000000000000001,0.8,0.9,1.}


Round[ygrids,0.01] doesn't fix it. (0.001 fixes all but the 7.0000x)

This is too simple to be this hard!

Help appreciated (version 10.1)

• Round[ygrids, 1/10] // N, Range[0, 1, 1/10] // N,N@Rationalize@Range[0, 1.0, 0.1]...
– ciao
Aug 12, 2015 at 0:56
• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is also useful for learning how to format your questions and answers. You may also find this this meta Q&A helpful Aug 12, 2015 at 1:02
• This needs to be marked as a duplicate, not closed as a "simple mistake." Aug 12, 2015 at 2:08
• A few links: (2915), (5580), (14122), (14511), (39126), (65298), (75528), (78298) Aug 12, 2015 at 2:12
• @Mr.Wizard: a duplicate of a simple mistake? ;-)
– ciao
Aug 12, 2015 at 2:31

## 1 Answer

I think you should cut the Gordian Knot and forget about rounding.

Plot[x, {x, 0, 1}, Ticks -> {Automatic, Range[0., 1., .1]}]


The lack of rounding has no visible affect on the plot.

• Yes, I will give this a try next time as I like the simplicity. I hope it works on more complicated graph axis ticks as well. Aug 12, 2015 at 16:27