Determination of equality between numeric items of the same or differing types in XBRL

Draft – for discussion purposes only

Hugh Wallis
Vice-Chair, XBRL International Specification Working Group 2003
Distinguished Software Architect, Hyperion Solutions

Since XBRL heavily leverages XML schema and because of the incompleteness and inconsistencies in the XML Schema type system, which have been discussed in various places including, for example, at XML.COM, it has become necessary to define a notion of equality (“v-equal”) between numeric values of different types in XBRL. As briefly mentioned in the above referenced article, XML is a string-based language. It therefore seems appropriate to use the lexical representation of numeric values as a means to determine equality between items in heterogeneous value spaces.

In addition, since XBRL provides a mechanism whereby it is possible to specify the number of significant figures to which a value is known to be accurate (called “precision”) and the number of decimal places to which a value is known to be accurate (called “decimals”) along with rules for the inference of the (“worst-case”) values of precision from a known or inferred value of decimals and rules for the inference of the (“worst-case”) values of decimals from the lexical representation of a value, there is a requirement to define equality between items expressed with different precision.

The following rules are proposed:
	
Two numeric items A and B are v-equal iff they have the identical XBRL canonical lexical representation when rounded to N significant figures where N is the lowest of:
 
i.	the specified precision for the A if precision is specified for A
ii.	the specified precision for B if precision is specified for B
iii.	the inferred precision for A if precision is not specified A
iv.	the inferred precision for B if precision is not specified for B

The canonical lexical representation to be used for comparison of values from different XML Schema or XBRL defined types may be determined by reference to the following table. Except where otherwise stated the XBRL canonical representation for a value of a particular XML Schema type is identical to the XML Schema canonical representation of that type.

Value space (or subset thereof) for first item, A	Value space (or subset thereof) for second item, B	Canonical forms of lexical representation to be used for comparison to determine whether A and B have the same value	
integer	decimal	Since integer is derived from decimal its value space is a subset of that for decimal. Therefore the XML Schema canonical representation for decimal as defined at http://www.w3.org/TR/xmlschema-2/#decimal - section 3.2.3.2	
decimal	float	A SHALL be mapped to the value space of B according to http://www.w3.org/TR/xmlschema-2/#float and the XML Schema canonical representation for float as defined in section 3.2.4.2	
decimal	double	A SHALL be mapped to the value space of B according to http://www.w3.org/TR/xmlschema-2/#double and the XML Schema canonical representation for float as defined in section 3.2.5.2	
float	double	For A, the XML Schema canonical representation for float according to section 3.2.4.2 at http://www.w3.org/TR/xmlschema-2/#float and for B, the XML Schema canonical representation for double according to section 3.2.5.2 at http://www.w3.org/TR/xmlschema-2/#double 	
fraction	fraction	The numerator and denominator of both A and B shall be converted into the XBRL canonical lexical representation for the fraction type as defined below. For A to be v-equal to B the resulting numerator of A must be identical to that of B and the resulting denominator of A must be identical to that of B. Note that no consideration need be given to precision since fractions are always considered to be of infinite precision.	
fraction	any other type	The numerator and denominator of A SHALL be converted to the XBRL canonical lexical representation for the fractionItemType type as defined below. The numerator SHALL then be divided by the denominator according to the rules defined in [IEEE 754-1985]. Since the resulting value may fall outside the value space for the XML Schema float type but, nevertheless, in the value space for the XML Schema double type, treat A as a double with this value and apply the above rules accordingly.	

The XBRL canonical lexical representation of the numerator and denominator of fractionItemType items SHALL be obtained from the original lexical representation of the item as follows:

i.	convert both the numerator and the denominator into their XML Schema canonical representations as floats according to section 3.2.4.2 at http://www.w3.org/TR/xmlschema-2/#float
ii.	subtract N from the exponent of both the numerator and denominator where N is the lower of the two exponent values.
iii.	express the resulting values in their XML Schema canonical representations as floats according to section 3.2.4.2 at http://www.w3.org/TR/xmlschema-2/#float

It should be noted that the above process does not necessarily conform to the rules or intent of floating-point arithmetic according to [IEEE 754-1985], nor produce the same results, but is specified in this way because of the intended use for fractionItemType in XBRL. It is intended, for example, that 1.23E4/5.67E8 has the same value as 1.23E0/5.67E4 regardless of whether floating-point division would produce that result. This approach is necessary because of the incomplete nature of the XML Schema type system.

Appendix

The following XML Schema fragments are relevant to the above discussion pertaining to fractions.

	<!-- nonZeroNonInfiniteFloat   -->
	<simpleType name="nonZeroNonInfiniteFloat">
		<annotation>
			<documentation>
As the name implies this is a float value that can not take the value ±0 or ±INF or NaN - it is used as the type for the denominator of a fractionItemType
		</documentation>
		</annotation>
		<union>
			<simpleType>
				<restriction base="float">
					<minExclusive value="0"/>
					<maxExclusive value="INF"/>
				</restriction>
			</simpleType>
			<simpleType>
				<restriction base="float">
					<minExclusive value="-INF"/>
					<maxExclusive value="-0"/>
				</restriction>
			</simpleType>
		</union>
	</simpleType>

	<!--                 fractionItemType        -->
	<complexType name="fractionItemType" final="extension">
		<sequence>
			<element name="numerator" type="float"/>
			<element name="denominator" type="xbrli:nonZeroNonInfiniteFloat"/>
		</sequence>
		<attribute name="numericContext" type="IDREF" use="required"/>
		<anyAttribute namespace="##other" processContents="lax"/>
	</complexType>