# Does Table handle Quantities differently?

I tried make a list with Table using quantities as inputs, but for some values of x, (e.g.,5,10,13..), the output is different than the same Table call without quantities. The last entry that I'm expecting in the list does not get created. Hoping someone can explain what Table does with quantities that makes it behave this way.

Example:

x=10;
Table[dist, {dist, Quantity[.2, "Feet"],
Quantity[2, "Feet"], (Quantity[2, "Feet"] - Quantity[.2, "Feet"])/x}]
Table[dist, {dist, .2, 2, (2 - .2)/10}]


yields:

{0.2ft,0.38ft,0.56ft,0.74ft,0.92ft,1.1ft,1.28ft,1.46ft,1.64ft,1.82ft}
{0.2,0.38,0.56,0.74,0.92,1.1,1.28,1.46,1.64,1.82,2.}

• This seems like a bug to me, don't know enough to say what causes it. A workaround is to use something like Quantity[Table[dist, {dist, xi, xf, dx}], "Feet"] Commented Nov 28, 2017 at 19:08
• Use x = 10; Table[ dist, {dist, Quantity[1/5, "Feet"], Quantity[2, "Feet"], (Quantity[2, "Feet"] - Quantity[1/5, "Feet"])/ x}] // N Commented Nov 28, 2017 at 19:41
• I would recommend the following: QuantityArray[Table[dist, {dist, .2, 2, (2 - .2)/10}], "Feet"]
– chuy
Commented Nov 28, 2017 at 21:11

You can use Subdivide instead to avoid issues with precision:

Subdivide[Quantity[.2,"Feet"], Quantity[2,"Feet"], 10]


{Quantity[0.2, "Feet"], Quantity[0.38, "Feet"], Quantity[0.56, "Feet"], Quantity[0.74, "Feet"], Quantity[0.92, "Feet"], Quantity[1.1, "Feet"], Quantity[1.28, "Feet"], Quantity[1.46, "Feet"], Quantity[1.64, "Feet"], Quantity[1.82, "Feet"], Quantity[2, "Feet"]}

or if you need to use Table:

Table[dist, {dist, Subdivide[Quantity[.2, "Feet"], Quantity[2, "Feet"], 10]}]


{Quantity[0.2, "Feet"], Quantity[0.38, "Feet"], Quantity[0.56, "Feet"], Quantity[0.74, "Feet"], Quantity[0.92, "Feet"], Quantity[1.1, "Feet"], Quantity[1.28, "Feet"], Quantity[1.46, "Feet"], Quantity[1.64, "Feet"], Quantity[1.82, "Feet"], Quantity[2, "Feet"]}