20

I would like to be able to call the Quantity function with a null unit so that it returns the original dimensionless value. For example,

Quantity[3.0,"NoUnits"]

would return 3.0. Is there a dimensionless unit?

Cassini
  • 5,556
  • 5
  • 28
  • 38
  • If it isn't there, I assume you could just add a definition to Quantity. What use of that do you have in mind? – Rojo Dec 21 '12 at 21:34
  • 1
    @Rojo: I run Monte Carlo simulations which output huge quantities of data with varying dimensions, so I created a data dictionary which describes each data type, including the units. When the simulation results are loaded into Mathematica, I use the data dictionary to attach units. However, some of the data types are dimensionless and rather than having a special "dimensionless" case for the code that calls Quantity, I'd rather have Quantity handle it. – Cassini Dec 21 '12 at 21:38

1 Answers1

27

I believe you can use "DimensionlessUnit" to get the desired result:

Quantity[3, "DimensionlessUnit"]
3

(note this is the unit produced by QuantityUnit on a dimensionless value):

QuantityUnit[3]
"DimensionlessUnit"
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
nikko
  • 736
  • 6
  • 7