15

When I evaluate this expression:

UnitConvert[Quantity[1920*1080, "Bytes"]*Quantity[24, "1/Seconds"] + 
     Quantity[44, "Kilohertz"]*Quantity[16, "Bits"], 
     Quantity["Megabytes"/"Seconds"]]

I get an error message:

UnitConvert::unkunit: Unable to interpret unit specification 1MB/s. >>

But the units should be compatible. FWIW, the old Units package has no problems with the equivalent:

Needs["Units`"]
Convert[1920*1080 Byte*24/Second + 44 Kilo Hertz*16 Bit, Mega Byte/Hour]

The only workaround I've found was to unit-convert the subexpressions myself:

UnitConvert[Quantity[1920*1080, "Bytes"]*Quantity[24, "1/Seconds"] + 
    UnitConvert[Quantity[44, "Kilohertz"], 1/"Seconds"]*
    UnitConvert[Quantity[16, "Bits"], "Bytes"], 
    Quantity["Megabytes"/"Seconds"]]

Is this a bug or am I using it wrong?

rm -rf
  • 88,781
  • 21
  • 293
  • 472
Niki Estner
  • 36,101
  • 3
  • 92
  • 152
  • 1
    I get 31159/625 MB/s on 9.0 for Mac OS X x86 (64-bit) (November 20, 2012) – rm -rf Nov 28 '12 at 21:25
  • UnitConvert[Quantity[89,"USCents"]/ Quantity[2,"Liters"],"USCents"/"FluidOunces"]//N gives: 1.31602per fluid ounce no "cents" per fluid ounce. This worked okay in the Units package prior to Mathematica 9 Also it converts 1 kilobytes to 1000 bytes (not 1024) –  Jan 10 '13 at 18:57
  • @Doug: I agree that that's probably a bug, but I'm not sure anyone from Wolfram Research will read about it here in a comment. You could ask in a new question if there's a workaround and you could mail the problem to Wolfram support directly. – Niki Estner Jan 11 '13 at 07:53
  • @Doug, it uses kilo and his family as standard 1000^something. Use "Kibibytes", mebi, etc – Rojo May 12 '13 at 15:27

1 Answers1

13

That code should work and it does work on my machine. The problem could be the following. You have only one part that requires Wolfram|Alpha interpretation:

Quantity[24, "1/Seconds"]

It is not built in unit - so it goes to Wolfram|Alpha for interpretation (how cool is that? ;-) ). This works almost always - unless something is wrong with internet connection, or there is some sort of latency problem. It works for me at least. Now if you want this to be evaluated without rerouting to Wolfram|Alpha, use

Quantity[24, 1/"Seconds"]

with "Seconds" of course built in. Now try this whole thing - should work:

UnitConvert[
  Quantity[1920*1080, "Bytes"]*
  Quantity[24, 1/"Seconds"] +
  Quantity[44, "Kilohertz"]*
  Quantity[16, "Bits"],
  Quantity["Megabytes"/"Seconds"]]

Quantity[31159/625, ("Megabytes")/("Seconds")]

Vitaliy Kaurov
  • 73,078
  • 9
  • 204
  • 355