Numbers

(Excerpt from "The MathML Handbook" by Pavi Sandhu)

The mn element is used to represent numbers, or more precisely numeric literals. A numeric literal is any sequence of characters that represents an unsigned integer or real number. Here are some examples:

<mn>1</mn>
<mn>6.67</mn>
<mn>2002</mn>
<mn>1.6e-19</mn>
<mn>0xAEFF</mn>
<mn>1100101</mn>

Negative numbers can be represented by including a "-" sign before the numeric literal in the same <mn> element, as shown below:

<mn>-1</mn>

However, it is preferable to place the minus sign in a separate mo element so that you provide additional information about the meaning of the markup for use by processing applications, as shown here:

<mo>-</mo><mn>1</mn>

A mn element is rendered as the characters in its content with no extra spacing around them. By default, the content is rendered in an unslanted font. However, you can specify a different rendering using the style attributes available for token elements.

Not all numbers should be represented using mn. For example, fractions are represented using the mfrac element, as shown here:

Presentation markup: equation 1

<mfrac><mn>1</mn><mn>2</mn></mfrac>

A named symbolic constant, such as Pi, is represented by an entity reference enclosed in an mi element, as shown below:

<mi>&pi;</mi>

Complex numbers are represented as an mrow element, which contains separate arguments for the real part, the imaginary part, and the operator between them, as shown here (note the use of the entity reference &InvisibleTimes; to denote multiplication between the imaginary part and the symbolic number i):

3.4 + 5i

<mrow>
  <mn>3.4</mn>
  <mo>+</mo>
  <mrow>
    <mn>5</mn>
    <mo>&InvisibleTimes;</mo>
    <mi>&ImaginaryI;</mi>
  </mrow>
</mrow>

   

<< back next >>

 

 

 


 

Copyright © CHARLES RIVER MEDIA, INC., Massachusetts (USA) 2003
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "The MathML Handbook" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.


CHARLES RIVER MEDIA, INC., 20 Downer Avenue, Suite 3, Hingham, Massachusetts 02043, United States of America