# PdfNumber class

> A PDF integer or real. The value is kept as canonical ASCII text so that reals read from a file survive a round trip exactly, with no floating point...

Namespace: [PdfNetStack.Objects](https://www.jadev-corp.com/api/pdfnetstack-objects/)  
Assembly: PdfNetStack.dll  
Package: `PdfNetStack`

A PDF integer or real. The value is kept as canonical ASCII text so that reals read from a
file survive a round trip exactly, with no floating point conversion involved.

```csharp
public sealed class PdfNumber : PdfObject
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[PdfObject](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfobject/) ← 
[PdfNumber](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfnumber/)

## Properties

### <a id="PdfNetStack_Objects_PdfNumber_IntegerValue"></a> IntegerValue

The integer value. Valid only when [IsInteger](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfnumber/#PdfNetStack_Objects_PdfNumber_IsInteger) is true.

```csharp
public long IntegerValue { get; }
```

#### Property Value

 [long](https://learn.microsoft.com/dotnet/api/system.int64)

### <a id="PdfNetStack_Objects_PdfNumber_IsInteger"></a> IsInteger

True for integers, false for reals.

```csharp
public bool IsInteger { get; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

## Methods

### <a id="PdfNetStack_Objects_PdfNumber_FromDouble_System_Double_"></a> FromDouble\(double\)

Creates a real, rounded to 6 decimal places and written without an exponent, as PDF
requires. Whole values become integers.

```csharp
public static PdfNumber FromDouble(double value)
```

#### Parameters

`value` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Returns

 [PdfNumber](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfnumber/)

#### Exceptions

 [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception)

<code class="paramref">value</code> is NaN or infinite.

### <a id="PdfNetStack_Objects_PdfNumber_FromInteger_System_Int64_"></a> FromInteger\(long\)

Creates an integer.

```csharp
public static PdfNumber FromInteger(long value)
```

#### Parameters

`value` [long](https://learn.microsoft.com/dotnet/api/system.int64)

#### Returns

 [PdfNumber](https://www.jadev-corp.com/api/pdfnetstack-objects/pdfnumber/)

### <a id="PdfNetStack_Objects_PdfNumber_ToDouble"></a> ToDouble\(\)

The value as a double. Exact for integers up to 2^53.

```csharp
public double ToDouble()
```

#### Returns

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Objects_PdfNumber_ToString"></a> ToString\(\)

The number as written in the file.

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

## Used in

- [Low level PDF objects in C#](https://www.jadev-corp.com/guides/low-level-objects/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-objects/pdfnumber/
