Esempio n. 1
0
// 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 easier to use.
//
func (context *Context) ToIntegral(a Quad, rounding RoundingMode) (r Quad) {
	var result C.Ret_decQuad_t
	assert_sane(context)

	result = C.mdq_to_integral(a.val, context.set, C.int(rounding))

	context.set = result.set
	return Quad{val: result.val}
}
Esempio n. 2
0
// 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)))
}