Exemple #1
0
// ToInt32 returns the int32 value from a.
// The rounding passed as argument is used, instead of the rounding mode of context which is ignored.
//
func (context *Context) ToInt32(a Quad, rounding RoundingMode) int32 {
	var result C.Ret_int32_t
	assert_sane(context)

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

	context.set = result.set
	return int32(result.val)
}
Exemple #2
0
// ToInt32 returns the int32 value from a.
//
// The status field of a is not checked.
// If you need to check the status of a, you can call a.Error().
//
func (a Quad) ToInt32(rounding RoundingMode) (int32, error) {
	var result C.Ret_int32_t

	result = C.mdq_to_int32(C.struct_Quad(a), C.int(rounding))

	if Status(result.status)&ErrorMask != 0 {
		return 0, newError(Status(result.status))
	}

	return int32(result.val), nil
}