Google Cloud Spanner v1 API - Struct SpannerNumeric (5.0.0-beta02)

public struct SpannerNumeric : IEquatable<SpannerNumeric>, IComparable<SpannerNumeric>, IComparable

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

Representation of the Spanner NUMERIC type, which has 38 digits of precision, and a fixed scale of 9 decimal places to the right of the decimal point

Namespace

Google.Cloud.Spanner.V1

Assembly

Google.Cloud.Spanner.V1.dll

Properties

Epsilon

public static SpannerNumeric Epsilon { get; }

The smallest positive value for SpannerNumeric, equal to 0.000000001.

Property Value
TypeDescription
SpannerNumeric

MaxValue

public static SpannerNumeric MaxValue { get; }

The maximum valid value for SpannerNumeric, equal to 99999999999999999999999999999.999999999.

Property Value
TypeDescription
SpannerNumeric

MinValue

public static SpannerNumeric MinValue { get; }

The minimum valid value for SpannerNumeric, equal to -99999999999999999999999999999.999999999.

Property Value
TypeDescription
SpannerNumeric

Zero

public static SpannerNumeric Zero { get; }

Zero represented as a SpannerNumeric. This is the default value for the type.

Property Value
TypeDescription
SpannerNumeric

Methods

CompareTo(SpannerNumeric)

public int CompareTo(SpannerNumeric other)

Compares this value with other.

Parameter
NameDescription
otherSpannerNumeric

The value to compare with this one

Returns
TypeDescription
int

A negative integer if this value is less than other; a positive integer if it's greater than other; zero if they're equal.

FromDecimal(decimal, LossOfPrecisionHandling)

public static SpannerNumeric FromDecimal(decimal value, LossOfPrecisionHandling lossOfPrecisionHandling)

Converts a decimal value to SpannerNumeric,

Parameters
NameDescription
valuedecimal

The value to convert

lossOfPrecisionHandlingLossOfPrecisionHandling

How to handle values with signficant digits that would be lost by the conversion.

Returns
TypeDescription
SpannerNumeric

The converted value.

Remarks

This conversion may silently lose precision, depending on lossOfPrecisionHandling.

GetHashCode()

public override int GetHashCode()

Returns a hash code for this value.

Returns
TypeDescription
int

A hash code for this value.

Overrides

Parse(string)

public static SpannerNumeric Parse(string text)

Parses a textual representation as a SpannerNumeric.

Parameter
NameDescription
textstring

The text to parse. Must not be null.

Returns
TypeDescription
SpannerNumeric

The parsed value.

Remarks

text must be a representation of a decimal value which can be represented by SpannerNumeric, using "." as a decimal place where one is specified, and a leading "-" for negative values. Leading zeroes and insignificant trailing digits are permitted.

Exceptions
TypeDescription
FormatException

The value could not be parsed as a SpannerNumeric.

ToDecimal(LossOfPrecisionHandling)

public decimal ToDecimal(LossOfPrecisionHandling lossOfPrecisionHandling)

Converts this value to decimal,

Parameter
NameDescription
lossOfPrecisionHandlingLossOfPrecisionHandling

How to handle values with signficant digits that would be lost by the conversion.

Returns
TypeDescription
decimal

The converted value.

Remarks

This conversion may silently lose precision, depending on lossOfPrecisionHandling, but will always throw OverflowException if value is out of the range of decimal.

Exceptions
TypeDescription
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, and only includes as many decimal places as are required to completely represent the value. If the value is between -1 and 1 exclusive, a "0" character is included before the decimal point.

Returns
TypeDescription
string

A canonical string representation of this value.

Overrides

TryParse(string, out SpannerNumeric)

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

Attempts to parse a textual representation of a SpannerNumeric value.

Parameters
NameDescription
textstring

The text to parse. Must not be null.

valueSpannerNumeric

The parsed value, or 0 on failure.

Returns
TypeDescription
bool

true if text was parsed successfully; false otherwise.

Remarks

See Parse(string) for format details. This method will return true if and only if Parse(string) would return without an exception.

Operators

operator +(SpannerNumeric, SpannerNumeric)

public static SpannerNumeric operator +(SpannerNumeric lhs, SpannerNumeric rhs)

Returns the result of adding two SpannerNumeric values together.

Parameters
NameDescription
lhsSpannerNumeric

The first value to add.

rhsSpannerNumeric

The second value to add.

Returns
TypeDescription
SpannerNumeric

The result of adding the two values.

operator ==(SpannerNumeric, SpannerNumeric)

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

Compares two values for equality.

Parameters
NameDescription
lhsSpannerNumeric

The first value to compare.

rhsSpannerNumeric

The second value to compare.

Returns
TypeDescription
bool

true if the two arguments are equal; false otherwise.

explicit operator decimal(SpannerNumeric)

public static explicit operator decimal(SpannerNumeric value)

Explicit conversion from SpannerNumeric to decimal.

Parameter
NameDescription
valueSpannerNumeric

The numeric value to convert.

Returns
TypeDescription
decimal

The result of the conversion.

Remarks

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.

explicit operator SpannerNumeric(decimal)

public static explicit operator SpannerNumeric(decimal value)

Explicit conversion from decimal to SpannerNumeric.

Parameter
NameDescription
valuedecimal

The decimal value to convert.

Returns
TypeDescription
SpannerNumeric

The result of the conversion.

Remarks

This conversion may silently lose precision. Use FromDecimal(decimal, LossOfPrecisionHandling) passing in Throw for the second argument to avoid any information loss.

implicit operator SpannerNumeric(int)

public static implicit operator SpannerNumeric(int value)

Implicit conversion from int to SpannerNumeric.

Parameter
NameDescription
valueint

The integer value to convert.

Returns
TypeDescription
SpannerNumeric

The result of the conversion.

Remarks

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

implicit operator SpannerNumeric(long)

public static implicit operator SpannerNumeric(long value)

Implicit conversion from long to SpannerNumeric.

Parameter
NameDescription
valuelong

The integer value to convert.

Returns
TypeDescription
SpannerNumeric

The result of the conversion.

implicit operator SpannerNumeric(ulong)

public static implicit operator SpannerNumeric(ulong value)

Implicit conversion from ulong to SpannerNumeric.

Parameter
NameDescription
valueulong

The integer value to convert.

Returns
TypeDescription
SpannerNumeric

The result of the conversion.

operator !=(SpannerNumeric, SpannerNumeric)

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

Compares two values for inequality.

Parameters
NameDescription
lhsSpannerNumeric

The first value to compare.

rhsSpannerNumeric

The second value to compare.

Returns
TypeDescription
bool

false if the two arguments are equal; true otherwise.

operator -(SpannerNumeric, SpannerNumeric)

public static SpannerNumeric operator -(SpannerNumeric lhs, SpannerNumeric rhs)

Returns the result of subtracting one SpannerNumeric value from another.

Parameters
NameDescription
lhsSpannerNumeric

The value to subtract from.

rhsSpannerNumeric

The value to subtract.

Returns
TypeDescription
SpannerNumeric

The result of subtracting rhs from lhs.

operator -(SpannerNumeric)

public static SpannerNumeric operator -(SpannerNumeric value)

The unary negation operator.

Parameter
NameDescription
valueSpannerNumeric

The value to negate.

Returns
TypeDescription
SpannerNumeric

The negation of value.

operator +(SpannerNumeric)

public static SpannerNumeric operator +(SpannerNumeric value)

The unary plus operator, provided mainly for consistency.

Parameter
NameDescription
valueSpannerNumeric

The value to return.

Returns
TypeDescription
SpannerNumeric

The original value.