nl_tokens: Returns the relative difference between two numbers i . e . { @code |a - b| / max ( |a| |b| ) } . <p > For cases where { @code a == 0 } { @code b == 0 } or { @code a } and { @code b } are extremely close traditional relative difference calculation breaks down . So in those instances we compute the difference relative to { @link Float#MIN_NORMAL } i . e . { @code |a - b| / Float . MIN_NORMAL } .
pl_tokens: public static float relativeDifference ( float a , float b ) { float absDiff = absoluteDifference ( a , b ) ; if ( Float . compare ( a , b ) == 0 ) { // Shortcut: handles infinities and NaNs. return 0 ; } else if ( a == 0 || b == 0 || absDiff < Float . MIN_NORMAL ) { return absDiff / Float . MIN_NORMAL ; } else { float maxAbsValue = Math . <mask> ( Math . abs ( a ) , Math . abs ( b ) ) ; return absDiff / maxAbsValue ; } }