# Google Cloud Spanner v1 API - Struct PgNumeric (5.13.0-beta07)

5.13.0-beta07 5.13.0-beta06 5.12.0 (latest) 5.11.0 5.10.0 5.9.0 5.8.0 5.7.0 5.6.0 5.5.0 5.4.0 5.3.0 5.2.0 5.1.0 5.0.0 4.6.0 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.15.1 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0

    public readonly struct PgNumeric : IEquatable<PgNumeric>, IComparable<PgNumeric>, IComparable

Reference documentation and code samples for the Google Cloud Spanner v1 API struct PgNumeric.

Representation of PostgreSQL numeric type which has max precision of 147455 and a max scale of 16383.

## Implements

[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable-1)[PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable)

## Inherited Members

[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)

## Namespace

[Google.Cloud.Spanner.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)

## Assembly

Google.Cloud.Spanner.V1.dll

## Properties

### MaxValue

    public static PgNumeric MaxValue { get; }

The maximum valid value for [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), equal to BigInteger.Pow(10, 147455) - 1

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` |   |

### MinValue

    public static PgNumeric MinValue { get; }

The minimum valid value for [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), equal to -(BigInteger.Pow(10, 147455) - 1)

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` |   |

### NaN

    public static PgNumeric NaN { get; }

NaN (Not a number) represented as a [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` |   |

### Zero

    public static PgNumeric Zero { get; }

Zero represented as a [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric). This is the default value for the type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` |   |

## Methods

### CompareTo(PgNumeric)

    public int CompareTo(PgNumeric other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

### FromDecimal(decimal)

    public static PgNumeric FromDecimal(decimal value)

Converts a [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric),

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.decimal` The value to convert |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` | The converted value. |

### GetHashCode()

    public override int GetHashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

**Overrides** [ValueType.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode)

### Parse(string)

    public static PgNumeric Parse(string text)

Parses a textual representation as a [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `text` | `https://learn.microsoft.com/dotnet/api/system.string` The text to parse. Must not be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` | The parsed value. |

**Remarks**
`text` must be a representation of a decimal value which can be represented by [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric),
using "." as a decimal place where one is specified, and a leading "-" for negative values. Leading zeroes and insignificant
trailing digits are permitted.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.formatexception` | The value could not be parsed as a [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric). |

### ToDecimal(LossOfPrecisionHandling)

    public decimal ToDecimal(LossOfPrecisionHandling lossOfPrecisionHandling)

Converts this value to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric),

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `lossOfPrecisionHandling` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.LossOfPrecisionHandling` How to handle values with signficant digits that would be lost by the conversion. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.decimal` | The converted value. |

**Remarks** This conversion may silently lose precision, depending on `lossOfPrecisionHandling`, but
will always throw [OverflowException](https://learn.microsoft.com/dotnet/api/system.overflowexception) if value is out of the range of [decimal](https://learn.microsoft.com/dotnet/api/system.decimal).

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.overflowexception` | This value is outside the range of [decimal](https://learn.microsoft.com/dotnet/api/system.decimal). |

### ToString()

    public override string ToString()

Returns a canonical string representation of this value. This always uses "." as a decimal point.
If the value is between -1 and 1 exclusive, a "0" character is included before the decimal point.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | A canonical string representation of this value. |

**Overrides** [ValueType.ToString()](https://learn.microsoft.com/dotnet/api/system.valuetype.tostring)

### TryParse(string, out PgNumeric)

    public static bool TryParse(string text, out PgNumeric value)

Attempts to parse a textual representation of a [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric) value.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `text` | `https://learn.microsoft.com/dotnet/api/system.string` The text to parse. Must not be null. |
| `value` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` The parsed value, or 0 on failure. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if `text` was parsed successfully; `false` otherwise. |

**Remarks** See [Parse(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric#Google_Cloud_Spanner_V1_PgNumeric_Parse_System_String_) for format details. This method will return `true` if and only if
[Parse(string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric#Google_Cloud_Spanner_V1_PgNumeric_Parse_System_String_) would return without an exception.

## Operators

### operator ==(PgNumeric, PgNumeric)

    public static bool operator ==(PgNumeric lhs, PgNumeric rhs)

Compares two values for equality.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` The first value to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` The second value to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `true` if the two arguments are equal; `false` otherwise. |

### explicit operator decimal(PgNumeric)

    public static explicit operator decimal(PgNumeric value)

Explicit conversion from [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric) to [decimal](https://learn.microsoft.com/dotnet/api/system.decimal).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` The numeric value to convert. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.decimal` | The result of the conversion. |

**Remarks** This conversion may silently lose precision, but will throw [OverflowException](https://learn.microsoft.com/dotnet/api/system.overflowexception) if the value is out of
range of [decimal](https://learn.microsoft.com/dotnet/api/system.decimal). Use [ToDecimal(LossOfPrecisionHandling)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric#Google_Cloud_Spanner_V1_PgNumeric_ToDecimal_Google_Cloud_Spanner_V1_LossOfPrecisionHandling_) passing in [Throw](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.LossOfPrecisionHandling#Google_Cloud_Spanner_V1_LossOfPrecisionHandling_Throw)
for the second argument to avoid any information loss.

### implicit operator PgNumeric(decimal)

    public static implicit operator PgNumeric(decimal value)

Implicit conversion from [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.decimal` The decimal value to convert. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` | The result of the conversion. |

### implicit operator PgNumeric(int)

    public static implicit operator PgNumeric(int value)

Implicit conversion from [int](https://learn.microsoft.com/dotnet/api/system.int32) to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.int32` The integer value to convert. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` | The result of the conversion. |

**Remarks** This conversion exists to avoid ambiguity between the 64-bit conversions when using an integer literal.

### implicit operator PgNumeric(long)

    public static implicit operator PgNumeric(long value)

Implicit conversion from [long](https://learn.microsoft.com/dotnet/api/system.int64) to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.int64` The integer value to convert. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` | The result of the conversion. |

### implicit operator PgNumeric(ulong)

    public static implicit operator PgNumeric(ulong value)

Implicit conversion from [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) to [PgNumeric](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.uint64` The integer value to convert. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` | The result of the conversion. |

### operator !=(PgNumeric, PgNumeric)

    public static bool operator !=(PgNumeric lhs, PgNumeric rhs)

Compares two values for inequality.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `lhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` The first value to compare. |
| `rhs` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric` The second value to compare. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` | `false` if the two arguments are equal; `true` otherwise. |