 
   equals: (other) ->
     if other instanceof Quantity
-      other_v = ucum.convert(other.value,ucum_unit(other.unit),ucum_unit(@unit))
-      @value == other_v
+
+      if (!@unit && other.unit )|| (@unit && !other.unit)
+        false
+      else if !@unit && !other.unit
+        @value == other.value
+      else
+        other_v = ucum.convert(other.value,ucum_unit(other.unit),ucum_unit(@unit))
+        decimalAdjust("round", @value, -8)  == decimalAdjust("round", other_v, -8)
 
   dividedBy: (other) ->
     @multiplyDivied(other,"/")

  if a instanceof Quantity and b instanceof Quantity
    # we will choose the unit of a to be the unit we return
    val = convert_value(b.value, b.unit, a.unit)
    if val
      new Quantity({unit: a.unit, value: a.value + val})
  else
    a.copy?().add?(b.value, clean_unit(b.unit))

module.exports.doSubtraction = (a,b) ->
  if a instanceof Quantity and b instanceof Quantity
    # we will choose the unit of a to be the unit we return
    val = convert_value(b.value, b.unit, a.unit)
    if val
      new Quantity({unit: a.unit, value: a.value - val})
  else
    a.copy?().add?(b.value * -1 , clean_unit(b.unit))


        delete ret.units[k]
  ret

ucum_comformant = (a, b) ->
  ret = true;
  Object.keys(a.units)
  .concat(Object.keys(b.units))
  .forEach( (k) ->
    if (a.units[k] != b.units[k])
      ret = false
  )
  ret


module.exports.createQuantity = createQuantity = (value,unit) ->
  new Quantity({value: value, unit: unit})

