本文整理汇总了Golang中C.struct_Quad函数的典型用法代码示例。如果您正苦于以下问题:Golang struct_Quad函数的具体用法?Golang struct_Quad怎么用?Golang struct_Quad使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了struct_Quad函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GreaterEqual
// GreaterEqual is true if a >= b.
//
// The status fields of a and b are not checked.
// If you need to check them, you can call a.Error() and b.Error().
//
func (a Quad) GreaterEqual(b Quad) bool {
var result C.uint32_t
result = C.mdq_compare(C.struct_Quad(a), C.struct_Quad(b))
if CmpFlag(result)&(CmpGreater|CmpEqual) != 0 {
return true
}
return false
}
示例2: Less
// Less is true if a < b.
//
// The status fields of a and b are not checked.
// If you need to check them, you can call a.Error() and b.Error().
//
func (a Quad) Less(b Quad) bool {
var result C.uint32_t
result = C.mdq_compare(C.struct_Quad(a), C.struct_Quad(b))
if CmpFlag(result)&CmpLess != 0 {
return true
}
return false
}
示例3: ToInt64
// ToInt64 returns the int64 value from a.
// The rounding passed as argument is used, instead of the rounding mode of context which is ignored.
//
// The status field of a is not checked.
// If you need to check the status of a, you can call a.Error().
//
// Note that ToInt64 is slower than ToInt32, because the underlying C decNumber package has no function that converts directly to int64.
// So, the number is first converted to string, and then to int64.
//
func (a Quad) ToInt64(rounding RoundingMode) (int64, error) {
var result C.Ret_int64_t
result = C.mdq_to_int64(C.struct_Quad(a), C.int(rounding))
if Status(result.status)&ErrorMask != 0 {
return 0, newError(Status(result.status))
}
return int64(result.val), nil
}
示例4: Round
// Round rounds (or truncate) 'a', with RoundHalfEven mode.
//
// n must be in the range [-35...34]. Else, Invalid Operation flag is set, and NaN is returned.
//
func (a Quad) Round(n int32) Quad {
return Quad(C.mdq_roundM(C.struct_Quad(a), C.int32_t(n), C.int(RoundHalfEven)))
}
示例5: DivInt
// DivInt returns the integral part of a/b.
//
func (a Quad) DivInt(b Quad) Quad {
return Quad(C.mdq_divide_integer(C.struct_Quad(a), C.struct_Quad(b)))
}
示例6: Quantize
// Quantize rounds a to the same pattern as b.
// b is just a model, its sign and coefficient value are ignored. Only its exponent is used.
// The result is the value of a, but with the same exponent as the pattern b.
//
// The representation of a number is:
//
// (-1)^sign coefficient * 10^exponent
// where coefficient is an integer storing 34 digits.
//
// Examples (with RoundHalfEven rounding mode):
// quantization of 134.6454 with 0.00001 is 134.64540
// 134.6454 with 0.00000 is 134.64540 the value of b has no importance
// 134.6454 with 1234.56789 is 134.64540 the value of b has no importance
// 134.6454 with 0.0001 is 134.6454
// 134.6454 with 0.01 is 134.65
// 134.6454 with 1 is 135
// 134.6454 with 1000000000 is 135 the value of b has no importance
// 134.6454 with 1E+2 is 1E+2
//
// 123e32 with 1 sets Invalid_operation error flag in status
// 123e32 with 1E1 is 1230000000000000000000000000000000E1
// 123e32 with 10 sets Invalid_operation error flag in status
//
// See also Round, RoundMode and Truncate methods, which are more useful methods.
//
func (a Quad) Quantize(b Quad, rounding RoundingMode) Quad {
return Quad(C.mdq_quantize(C.struct_Quad(a), C.struct_Quad(b), C.int(rounding)))
}
示例7: Abs
// Abs returns the absolute value of a.
//
func (a Quad) Abs() Quad {
return Quad(C.mdq_abs(C.struct_Quad(a)))
}
示例8: Min
// Min returns the smaller of a and b.
// If either a or b is NaN then the other argument is the result.
//
func Min(a Quad, b Quad) Quad {
return Quad(C.mdq_min(C.struct_Quad(a), C.struct_Quad(b)))
}
示例9: ToIntegral
// ToIntegral returns the value of a rounded to an integral value.
//
// The representation of a number is:
//
// (-1)^sign coefficient * 10^exponent
// where coefficient is an integer storing 34 digits.
//
// - If exponent < 0, the least significant digits are discarded, so that new exponent becomes 0.
// Internally, it calls Quantize(a, 1E0) with specified rounding.
// - If exponent >= 0, the number remains unchanged.
//
// E.g. 12.345678e2 is 12345678E-4 --> 1235E0
// 123e5 is 123E5 remains 123E5
//
// See also Round, RoundMode and Truncate methods, which are more convenient to use.
//
func (a Quad) ToIntegral(rounding RoundingMode) Quad {
return Quad(C.mdq_to_integral(C.struct_Quad(a), C.int(rounding)))
}
示例10: Mod
// Mod returns the modulo of a and b.
//
func (a Quad) Mod(b Quad) Quad {
return Quad(C.mdq_remainder(C.struct_Quad(a), C.struct_Quad(b)))
}
示例11: Max
// Max returns the larger of a and b.
// If either a or b is NaN then the other argument is the result.
//
func Max(a Quad, b Quad) Quad {
return Quad(C.mdq_max(C.struct_Quad(a), C.struct_Quad(b)))
}
示例12: Div
// Div returns a/b.
//
func (a Quad) Div(b Quad) Quad {
return Quad(C.mdq_divide(C.struct_Quad(a), C.struct_Quad(b)))
}
示例13: RoundWithMode
// RoundWithMode rounds (or truncate) 'a', with the mode passed as argument.
// You must pass a constant RoundCeiling, RoundHalfEven, etc as argument.
//
// n must be in the range [-35...34]. Else, Invalid Operation flag is set, and NaN is returned.
//
func (a Quad) RoundWithMode(n int32, rounding RoundingMode) Quad {
return Quad(C.mdq_roundM(C.struct_Quad(a), C.int32_t(n), C.int(rounding)))
}
示例14: Mul
// Mul returns a * b.
//
func (a Quad) Mul(b Quad) Quad {
return Quad(C.mdq_multiply(C.struct_Quad(a), C.struct_Quad(b)))
}
示例15: Sub
// Sub returns a - b.
//
func (a Quad) Sub(b Quad) Quad {
return Quad(C.mdq_subtract(C.struct_Quad(a), C.struct_Quad(b)))
}