MbNumberU

use | constructors | constants | strings | comparisons | conversions | get/set

Use

 

 

Constructors

MbNumberU(str:String, dim_:String="unknown")

static makeNumberU(num_:Number, units_:String, dim_:String="unknown"):MbNumberU

Constants

Comparison codes

Note: MbNumberU has 2 major attribute: the number, and the units. These two act together to determine the value of the measurement. The comparison codes used by various methods follow, with examples of MbNumberU compared to 5cm.

ALL_RIGHT number and units match 5cm
ALL_WRONG nothing matches 50m
NUM_ONLY_RIGHT number is correct but units are wrong
(hence value also wrong)
5m
UNIT_RIGHT_TOO_BIG units are right but number is too big 50cm
UNIT_RIGHT_TOO_SMALL units are right but number is too small 0.5cm
MAG_ONLY_RIGHT the value is correct but number and units are both wrong 50mm

String manipulation

 

toString():String

returns a string with number only (if no units defined) or number + standard units
number is given in sig dis (displayPrec)

expandedUnitName(str:String):String

returns standard LONG form of unit name

Comparison functions

compMag(compU:MbNumberU):Number

compares the number AND units, returns a comparison code

compLit(compU:MbNumberU, tol:Number):String

compares number AND units, returns a comparison code

sameSize(compU:MbNumberU, tol:Number):Boolean

returns true only if number AND unit match

sameUnits(compUnits:MbNumberU):Boolean

returns true only if units match (number does not matter)

sameDim(compUnits:MbNumberU):Boolean

returns true only if dimension of units of the same (i.e., both are length, both are weight)

Conversion Functions

convertTo(newStr:String):MbNumberU

does conversion if possible
conditions: same dimension, known conversion factor
new conversion factors should be entered into the class.

Getters/Setters

getNumber():Number
getUnits():String
isInvalid():Boolean