Struct BigQueryNumeric (2.2.0)

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

Representation of the BigQuery 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.BigQuery.V2

Assembly

Google.Cloud.BigQuery.V2.dll

Properties

Epsilon

public static BigQueryNumeric Epsilon { get; }

The smallest positive value for BigQueryNumeric, equal to 0.000000001.

Property Value
TypeDescription
BigQueryNumeric

MaxValue

public static BigQueryNumeric MaxValue { get; }

The maximum valid value for BigQueryNumeric, equal to 99999999999999999999999999999.999999999.

Property Value
TypeDescription
BigQueryNumeric

MinValue

public static BigQueryNumeric MinValue { get; }

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

Property Value
TypeDescription
BigQueryNumeric

Zero

public static BigQueryNumeric Zero { get; }

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

Property Value
TypeDescription
BigQueryNumeric

Methods

CompareTo(BigQueryNumeric)

public int CompareTo(BigQueryNumeric other)

Compares this value with other.

Parameter
NameDescription
otherBigQueryNumeric

The value to compare with this one

Returns
TypeDescription
Int32

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 BigQueryNumeric FromDecimal(decimal value, LossOfPrecisionHandling lossOfPrecisionHandling)

Converts a Decimal value to BigQueryNumeric,

Parameters
NameDescription
valueDecimal

The value to convert

lossOfPrecisionHandlingLossOfPrecisionHandling

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

Returns
TypeDescription
BigQueryNumeric

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
Int32

A hash code for this value.

Overrides

Parse(String)

public static BigQueryNumeric Parse(string text)

Parses a textual representation as a BigQueryNumeric.

Parameter
NameDescription
textString

The text to parse. Must not be null.

Returns
TypeDescription
BigQueryNumeric

The parsed value.

Remarks

text must be a representation of a decimal value which can be represented by BigQueryNumeric, 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 BigQueryNumeric.

ToDecimal(LossOfPrecisionHandling)

public decimal ToDecimal(LossOfPrecisionHandling lossOfPrecisionHandling)

Converts this value to BigQueryNumeric,

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 BigQueryNumeric)

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

Attempts to parse a textual representation of a BigQueryNumeric value.

Parameters
NameDescription
textString

The text to parse. Must not be null.

valueBigQueryNumeric

The parsed value, or 0 on failure.

Returns
TypeDescription
Boolean

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

Addition(BigQueryNumeric, BigQueryNumeric)

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

Returns the result of adding two BigQueryNumeric values together.

Parameters
NameDescription
lhsBigQueryNumeric

The first value to add.

rhsBigQueryNumeric

The second value to add.

Returns
TypeDescription
BigQueryNumeric

The result of adding the two values.

Equality(BigQueryNumeric, BigQueryNumeric)

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

Compares two values for equality.

Parameters
NameDescription
lhsBigQueryNumeric

The first value to compare.

rhsBigQueryNumeric

The second value to compare.

Returns
TypeDescription
Boolean

true if the two arguments are equal; false otherwise.

Explicit(BigQueryNumeric to Decimal)

public static explicit operator decimal (BigQueryNumeric value)

Explicit conversion from BigQueryNumeric to Decimal.

Parameter
NameDescription
valueBigQueryNumeric

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(Decimal to BigQueryNumeric)

public static explicit operator BigQueryNumeric(decimal value)

Explicit conversion from Decimal to BigQueryNumeric.

Parameter
NameDescription
valueDecimal

The decimal value to convert.

Returns
TypeDescription
BigQueryNumeric

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(Int32 to BigQueryNumeric)

public static implicit operator BigQueryNumeric(int value)

Implicit conversion from Int32 to BigQueryNumeric.

Parameter
NameDescription
valueInt32

The integer value to convert.

Returns
TypeDescription
BigQueryNumeric

The result of the conversion.

Remarks

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

Implicit(Int64 to BigQueryNumeric)

public static implicit operator BigQueryNumeric(long value)

Implicit conversion from Int64 to BigQueryNumeric.

Parameter
NameDescription
valueInt64

The integer value to convert.

Returns
TypeDescription
BigQueryNumeric

The result of the conversion.

Implicit(UInt64 to BigQueryNumeric)

public static implicit operator BigQueryNumeric(ulong value)

Implicit conversion from UInt64 to BigQueryNumeric.

Parameter
NameDescription
valueUInt64

The integer value to convert.

Returns
TypeDescription
BigQueryNumeric

The result of the conversion.

Inequality(BigQueryNumeric, BigQueryNumeric)

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

Compares two values for inequality.

Parameters
NameDescription
lhsBigQueryNumeric

The first value to compare.

rhsBigQueryNumeric

The second value to compare.

Returns
TypeDescription
Boolean

false if the two arguments are equal; true otherwise.

Subtraction(BigQueryNumeric, BigQueryNumeric)

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

Returns the result of subtracting one BigQueryNumeric value from another.

Parameters
NameDescription
lhsBigQueryNumeric

The value to subtract from.

rhsBigQueryNumeric

The value to subtract.

Returns
TypeDescription
BigQueryNumeric

The result of subtracting rhs from lhs.

UnaryNegation(BigQueryNumeric)

public static BigQueryNumeric operator -(BigQueryNumeric value)

The unary negation operator.

Parameter
NameDescription
valueBigQueryNumeric

The value to negate.

Returns
TypeDescription
BigQueryNumeric

The negation of value.

UnaryPlus(BigQueryNumeric)

public static BigQueryNumeric operator +(BigQueryNumeric value)

The unary plus operator, provided mainly for consistency.

Parameter
NameDescription
valueBigQueryNumeric

The value to return.

Returns
TypeDescription
BigQueryNumeric

The original value.

Explicit Interface Implementations

IComparable.CompareTo(Object)

int IComparable.CompareTo(object obj)

Implementation of CompareTo(Object) to compare two BigQueryNumeric values.

Parameter
NameDescription
objObject

The object to compare this value with.

Returns
TypeDescription
Int32

The result of comparing this value with obj. obj is null, this method returns a value greater than 0.

Remarks

This uses explicit interface implementation to avoid it being called accidentally. The generic implementation should usually be preferred.

Exceptions
TypeDescription
ArgumentException

obj is non-null but does not refer to an instance of BigQueryNumeric.