text must be a representation of a decimal value which can be represented by PgNumeric,
using "." as a decimal place where one is specified, and a leading "-" for negative values. Leading zeroes and insignificant
trailing digits are permitted.
This conversion may silently lose precision, depending on lossOfPrecisionHandling, but
will always throw OverflowException if value is out of the range of decimal.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003eThe latest version of the Google Cloud Spanner v1 API's PgNumeric struct is 5.0.0-beta05, with multiple prior versions available.\u003c/p\u003e\n"],["\u003cp\u003ePgNumeric represents a PostgreSQL numeric type that supports a maximum precision of 147455 and a maximum scale of 16383.\u003c/p\u003e\n"],["\u003cp\u003ePgNumeric includes static properties such as MaxValue, MinValue, NaN, and Zero to represent extreme values, not a number, and zero, respectively.\u003c/p\u003e\n"],["\u003cp\u003ePgNumeric provides methods for comparison, conversion from and to decimal, parsing from strings, and checking for equality or inequality, as well as implicit and explicit conversions to other primitive types.\u003c/p\u003e\n"],["\u003cp\u003eThe Google.Cloud.Spanner.V1 namespace contains the PgNumeric struct.\u003c/p\u003e\n"]]],[],null,["# Google Cloud Spanner v1 API - Struct PgNumeric (5.1.0)\n\nVersion latestkeyboard_arrow_down\n\n- [5.1.0 (latest)](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric)\n- [5.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/5.0.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.6.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.5.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.4.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.4.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.3.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.3.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.2.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.2.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.1.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.1.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [4.0.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/4.0.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.15.1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.15.1/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.14.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.13.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.12.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.11.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.10.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.9.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.8.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.7.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.6.0/Google.Cloud.Spanner.V1.PgNumeric)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Spanner.V1/3.5.0/Google.Cloud.Spanner.V1.PgNumeric) \n\n public readonly struct PgNumeric : IEquatable\u003cPgNumeric\u003e, IComparable\u003cPgNumeric\u003e, IComparable\n\nReference documentation and code samples for the Google Cloud Spanner v1 API struct PgNumeric.\n\nRepresentation of PostgreSQL numeric type which has max precision of 147455 and a max scale of 16383. \n\nImplements\n----------\n\n[IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable-1)[PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), [IComparable](https://learn.microsoft.com/dotnet/api/system.icomparable) \n\nInherited Members\n-----------------\n\n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)\n\nNamespace\n---------\n\n[Google.Cloud.Spanner.V1](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1)\n\nAssembly\n--------\n\nGoogle.Cloud.Spanner.V1.dll\n\nProperties\n----------\n\n### MaxValue\n\n public static PgNumeric MaxValue { get; }\n\nThe maximum valid value for [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), equal to BigInteger.Pow(10, 147455) - 1\n\n### MinValue\n\n public static PgNumeric MinValue { get; }\n\nThe minimum valid value for [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric), equal to -(BigInteger.Pow(10, 147455) - 1)\n\n### NaN\n\n public static PgNumeric NaN { get; }\n\nNaN (Not a number) represented as a [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).\n\n### Zero\n\n public static PgNumeric Zero { get; }\n\nZero represented as a [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric). This is the default value for the type.\n\nMethods\n-------\n\n### CompareTo(PgNumeric)\n\n public int CompareTo(PgNumeric other)\n\n### FromDecimal(decimal)\n\n public static PgNumeric FromDecimal(decimal value)\n\nConverts a [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) value to [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric),\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[ValueType.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.valuetype.gethashcode)\n\n### Parse(string)\n\n public static PgNumeric Parse(string text)\n\nParses a textual representation as a [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).\n\n**Remarks** \n\n`text` must be a representation of a decimal value which can be represented by [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric),\nusing \".\" as a decimal place where one is specified, and a leading \"-\" for negative values. Leading zeroes and insignificant\ntrailing digits are permitted.\n\n### ToDecimal(LossOfPrecisionHandling)\n\n public decimal ToDecimal(LossOfPrecisionHandling lossOfPrecisionHandling)\n\nConverts this value to [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric),\n\n**Remarks** \nThis conversion may silently lose precision, depending on `lossOfPrecisionHandling`, but\nwill 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).\n\n### ToString()\n\n public override string ToString()\n\nReturns a canonical string representation of this value. This always uses \".\" as a decimal point.\nIf the value is between -1 and 1 exclusive, a \"0\" character is included before the decimal point.\n\n**Overrides** \n[ValueType.ToString()](https://learn.microsoft.com/dotnet/api/system.valuetype.tostring)\n\n### TryParse(string, out PgNumeric)\n\n public static bool TryParse(string text, out PgNumeric value)\n\nAttempts to parse a textual representation of a [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric) value.\n\n**Remarks** \nSee [Parse(string)](/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\n[Parse(string)](/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.\n\nOperators\n---------\n\n### operator ==(PgNumeric, PgNumeric)\n\n public static bool operator ==(PgNumeric lhs, PgNumeric rhs)\n\nCompares two values for equality.\n\n### explicit operator decimal(PgNumeric)\n\n public static explicit operator decimal(PgNumeric value)\n\nExplicit conversion from [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric) to [decimal](https://learn.microsoft.com/dotnet/api/system.decimal).\n\n**Remarks** \nThis conversion may silently lose precision, but will throw [OverflowException](https://learn.microsoft.com/dotnet/api/system.overflowexception) if the value is out of\nrange of [decimal](https://learn.microsoft.com/dotnet/api/system.decimal). Use [ToDecimal(LossOfPrecisionHandling)](/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](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.LossOfPrecisionHandling#Google_Cloud_Spanner_V1_LossOfPrecisionHandling_Throw)\nfor the second argument to avoid any information loss.\n\n### implicit operator PgNumeric(decimal)\n\n public static implicit operator PgNumeric(decimal value)\n\nImplicit conversion from [decimal](https://learn.microsoft.com/dotnet/api/system.decimal) to [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).\n\n### implicit operator PgNumeric(int)\n\n public static implicit operator PgNumeric(int value)\n\nImplicit conversion from [int](https://learn.microsoft.com/dotnet/api/system.int32) to [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).\n\n**Remarks** \nThis conversion exists to avoid ambiguity between the 64-bit conversions when using an integer literal.\n\n### implicit operator PgNumeric(long)\n\n public static implicit operator PgNumeric(long value)\n\nImplicit conversion from [long](https://learn.microsoft.com/dotnet/api/system.int64) to [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).\n\n### implicit operator PgNumeric(ulong)\n\n public static implicit operator PgNumeric(ulong value)\n\nImplicit conversion from [ulong](https://learn.microsoft.com/dotnet/api/system.uint64) to [PgNumeric](/dotnet/docs/reference/Google.Cloud.Spanner.V1/latest/Google.Cloud.Spanner.V1.PgNumeric).\n\n### operator !=(PgNumeric, PgNumeric)\n\n public static bool operator !=(PgNumeric lhs, PgNumeric rhs)\n\nCompares two values for inequality."]]