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.
Namespace
Google.Cloud.Spanner.V1Assembly
Google.Cloud.Spanner.V1.dll
Properties
MaxValue
public static PgNumeric MaxValue { get; }
The maximum valid value for PgNumeric, equal to BigInteger.Pow(10, 147455) - 1
Property Value | |
---|---|
Type | Description |
PgNumeric |
MinValue
public static PgNumeric MinValue { get; }
The minimum valid value for PgNumeric, equal to -(BigInteger.Pow(10, 147455) - 1)
Property Value | |
---|---|
Type | Description |
PgNumeric |
NaN
public static PgNumeric NaN { get; }
NaN (Not a number) represented as a PgNumeric.
Property Value | |
---|---|
Type | Description |
PgNumeric |
Zero
public static PgNumeric Zero { get; }
Zero represented as a PgNumeric. This is the default value for the type.
Property Value | |
---|---|
Type | Description |
PgNumeric |
Methods
CompareTo(PgNumeric)
public int CompareTo(PgNumeric other)
Parameter | |
---|---|
Name | Description |
other | PgNumeric |
Returns | |
---|---|
Type | Description |
int |
FromDecimal(decimal)
public static PgNumeric FromDecimal(decimal value)
Parameter | |
---|---|
Name | Description |
value | decimal The value to convert |
Returns | |
---|---|
Type | Description |
PgNumeric | The converted value. |
GetHashCode()
public override int GetHashCode()
Returns | |
---|---|
Type | Description |
int |
Parse(string)
public static PgNumeric Parse(string text)
Parses a textual representation as a PgNumeric.
Parameter | |
---|---|
Name | Description |
text | string The text to parse. Must not be null. |
Returns | |
---|---|
Type | Description |
PgNumeric | The parsed value. |
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.
Exceptions | |
---|---|
Type | Description |
FormatException | The value could not be parsed as a PgNumeric. |
ToDecimal(LossOfPrecisionHandling)
public decimal ToDecimal(LossOfPrecisionHandling lossOfPrecisionHandling)
Converts this value to PgNumeric,
Parameter | |
---|---|
Name | Description |
lossOfPrecisionHandling | LossOfPrecisionHandling How to handle values with signficant digits that would be lost by the conversion. |
Returns | |
---|---|
Type | Description |
decimal | The converted value. |
This conversion may silently lose precision, depending on lossOfPrecisionHandling
, but
will always throw OverflowException if value is out of the range of decimal.
Exceptions | |
---|---|
Type | Description |
OverflowException | This value is outside the range of 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 |
string | A canonical string representation of this value. |
TryParse(string, out PgNumeric)
public static bool TryParse(string text, out PgNumeric value)
Attempts to parse a textual representation of a PgNumeric value.
Parameters | |
---|---|
Name | Description |
text | string The text to parse. Must not be null. |
value | PgNumeric The parsed value, or 0 on failure. |
Returns | |
---|---|
Type | Description |
bool |
|
See Parse(string) for format details. This method will return true
if and only if
Parse(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 | PgNumeric The first value to compare. |
rhs | PgNumeric The second value to compare. |
Returns | |
---|---|
Type | Description |
bool |
|
explicit operator decimal(PgNumeric)
public static explicit operator decimal(PgNumeric value)
Parameter | |
---|---|
Name | Description |
value | PgNumeric The numeric value to convert. |
Returns | |
---|---|
Type | Description |
decimal | The result of the conversion. |
This conversion may silently lose precision, but will throw OverflowException if the value is out of range of decimal. Use ToDecimal(LossOfPrecisionHandling) passing in Throw for the second argument to avoid any information loss.
implicit operator PgNumeric(decimal)
public static implicit operator PgNumeric(decimal value)
Parameter | |
---|---|
Name | Description |
value | decimal The decimal value to convert. |
Returns | |
---|---|
Type | Description |
PgNumeric | The result of the conversion. |
implicit operator PgNumeric(int)
public static implicit operator PgNumeric(int value)
Parameter | |
---|---|
Name | Description |
value | int The integer value to convert. |
Returns | |
---|---|
Type | Description |
PgNumeric | The result of the conversion. |
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)
Parameter | |
---|---|
Name | Description |
value | long The integer value to convert. |
Returns | |
---|---|
Type | Description |
PgNumeric | The result of the conversion. |
implicit operator PgNumeric(ulong)
public static implicit operator PgNumeric(ulong value)
Parameter | |
---|---|
Name | Description |
value | ulong The integer value to convert. |
Returns | |
---|---|
Type | Description |
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 | PgNumeric The first value to compare. |
rhs | PgNumeric The second value to compare. |
Returns | |
---|---|
Type | Description |
bool |
|