> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.nimbleapps.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# XmlNumberHandling

> Specifies how [XmlSerializer](/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlSerializer) handles the named floating-point literals `INF`, `-INF`, and `NaN` when seri...

## Definition

**Assembly:** CloudNimble.XmlEssentials.dll

**Namespace:** CloudNimble.Text.Xml.Serialization

**Inheritance:** System.Enum

## Syntax

```csharp theme={"dark"}
CloudNimble.Text.Xml.Serialization.XmlNumberHandling
```

## Summary

Specifies how [XmlSerializer](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlSerializer.md) handles the named floating-point literals `INF`, `-INF`, and `NaN`
when serializing and deserializing.

## Usage

`XmlNumberHandling` says whether the XML Schema names for the floating-point values that aren't numbers are allowed: `INF`, `-INF`, and `NaN`. Set it through `XmlSerializerOptions.NumberHandling`. It applies to `float` and `double` values.

| Value | Behavior |
| - | - |
| `AllowNamedFloatingPointLiterals` (default) | `double.PositiveInfinity` is written as `INF`, `double.NegativeInfinity` as `-INF`, and `double.NaN` as `NaN`, and those names are accepted when reading. |
| `Strict` | Writing one of those values, or reading one of those names, throws an [`XmlException`](https://easyaf.nimbleapps.cloud/xmlessentials/api-reference/CloudNimble/Text/Xml/XmlException). |

Use `Strict` when the consumer of the XML treats the element as a plain decimal number and would fail on a name.

## Considerations

* The default is the reverse of System.Text.Json, where named floating-point literals must be turned on. `INF`, `-INF`, and `NaN` are part of the XML Schema definition of `float` and `double`, so XML consumers that follow XML Schema accept them.
* The setting doesn't affect integers or `decimal`, which have no such values.
* Unlike `JsonNumberHandling`, there are no values for reading numbers from quoted strings. Every XML value is text already.

## Values

| Name | Value | Description |
| - | - | - |
| `Strict` | 0 | Strict handling, in which `INF`, `-INF`, and `NaN` are rejected on both reading and writing. |
| `AllowNamedFloatingPointLiterals` | 1 | Lenient handling, in which the XML Schema named literals `INF`, `-INF`, and `NaN` are read, in any letter case, and written. |

## Related APIs

* CloudNimble.Text.Xml.XmlSerializerOptions
* CloudNimble.Text.Xml.XmlException


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.