Beispiel #1
0
// Compare compares the value of a and b.
//
//     If a <  b,        returns CmpLess
//     If a == b,        returns CmpGreater
//     If a >  b,        returns CmpEqual
//     If a or b is Nan, returns CmpNaN
//
// Compare usually doesn't set status flag, except if an argument is sNaN (signaling NaN), which sets FlagInvalidOperation.
//
// Example:
//
//     if ctx.Compare(a, b) & (CmpGreater|CmpEqual) != 0 { // if a >= b
//         ...
//     }
//
func (context *Context) Compare(a Quad, b Quad) CmpFlag {
	var result C.Ret_uint32_t
	assert_sane(context)

	result = C.mdq_compare(a.val, b.val, context.set)

	context.set = result.set
	return CmpFlag(result.val)
}
Beispiel #2
0
// 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
}
Beispiel #3
0
// 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
}
Beispiel #4
0
// Less is same as Cmp(a, b, CmpLess)
//
// This function usually doesn't set status flag, except if an argument is sNaN (signaling NaN), which sets FlagInvalidOperation.
//
func (context *Context) Less(a Quad, b Quad) bool {
	var result C.Ret_uint32_t
	assert_sane(context)

	result = C.mdq_compare(a.val, b.val, context.set)

	context.set = result.set
	if CmpFlag(result.val)&CmpLess != 0 {
		return true
	}

	return false
}
Beispiel #5
0
// GreaterEqual is same as Cmp(a, b, CmpGreater|CmpEqual)
//
// This function usually doesn't set status flag, except if an argument is sNaN (signaling NaN), which sets FlagInvalidOperation.
//
func (context *Context) GreaterEqual(a Quad, b Quad) bool {
	var result C.Ret_uint32_t
	assert_sane(context)

	result = C.mdq_compare(a.val, b.val, context.set)

	context.set = result.set
	if CmpFlag(result.val)&(CmpGreater|CmpEqual) != 0 {
		return true
	}

	return false
}