[udunits] ucar.units.ScaledUnit oddities

Hello,

Consider this example Java code:

   Unit metersPerSecondUnit = format.parse("m/s");

   Unit unit1 = format.parse("60 m / minute");
   Unit unit2 = format.parse("600 m / 10 minutes");

   System.out.println(unit1.getCanonicalString());  // Prints "1.0 m.s-1"
   System.out.println(unit2.getCanonicalString());  // Prints "3600.0 m.s"

System.out.println(metersPerSecondUnit.isCompatible(unit1)); // Prints "true" System.out.println(metersPerSecondUnit.isCompatible(unit2)); // Prints "false"

   System.out.println(unit1.equals(unit2));  // Prints "false"

Pretty strange results, huh? Is the parse method intended to support a unit spec such as "600 m / 10 minutes"? It certainly didn't throw an exception when I tried.



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the udunits archives: