Documentation ¶
Index ¶
- Constants
- Variables
- func Abs(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error
- func Add(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error
- func AppendQuad(dst []byte, a *MyQuad) []byte
- func Append_compressed_bytes(dest []byte, a MyQuad) (dest_modified []byte, length uint16)
- func Byteslice2Cstring(bs []byte) *C.char
- func Byteslice_into_C(p *C.char, length C.size_t) []byte
- func Ceiling(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error
- func Check_equality_FOR_TEST(a *MyQuad, b *MyQuad) bool
- func Compare(a *MyQuad, b *MyQuad) int
- func Copy(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error
- func Divide(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error
- func Floor(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error
- func From_bytes(r *MyQuad, precision uint16, scale uint16, value []byte) *rsql.Error
- func From_bytes_raw(r *MyQuad, value []byte) *rsql.Error
- func From_bytes_with_implied_p_s(r *MyQuad, value []byte) (precision uint16, scale uint16, rsql_err *rsql.Error)
- func From_int32(r *MyQuad, precision uint16, scale uint16, value int32) *rsql.Error
- func From_int32_raw(r *MyQuad, value int32)
- func From_int64(r *MyQuad, precision uint16, scale uint16, value int64) *rsql.Error
- func From_int64_raw(r *MyQuad, value int64)
- func From_string(r *MyQuad, precision uint16, scale uint16, value string) *rsql.Error
- func From_string_raw(r *MyQuad, value string) *rsql.Error
- func From_string_with_implied_p_s(r *MyQuad, value string) (precision uint16, scale uint16, rsql_err *rsql.Error)
- func Hash(a *MyQuad) uint32
- func Is_negative(r *MyQuad) bool
- func Is_zero(r *MyQuad) bool
- func Multiply(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error
- func Plain_zero(r *MyQuad)
- func Power(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b float64) *rsql.Error
- func Round(r *MyQuad, precision uint16, scale uint16, a *MyQuad, a_precision uint16, ...) *rsql.Error
- func Round_for_formatting(r *MyQuad, a *MyQuad, b int32) *rsql.Error
- func Sign(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error
- func Subtract(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error
- func To_byte_representation(a MyQuad) (res [S_DECQUAD_Bytes]byte)
- func To_float64(a *MyQuad) (float64, *rsql.Error)
- func To_int32_round(a *MyQuad) (int32, *rsql.Error)
- func To_int32_truncate(a *MyQuad) (int32, *rsql.Error)
- func To_int64_round(a *MyQuad) (int64, *rsql.Error)
- func To_int64_truncate(a *MyQuad) (int64, *rsql.Error)
- func Unary_minus(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error
- func Zero(r *MyQuad, precision uint16, scale uint16)
- type MyQuad
Constants ¶
const ( S_DECQUAD_Pmax = C.DECQUAD_Pmax // number of digits in coefficient S_DECQUAD_Bytes = C.DECQUAD_Bytes // size in bytes of decQuad S_DECQUAD_String = C.DECQUAD_String // buffer capacity for C.decQuadToString() S_STRING_RAW_CAPACITY = C.S_STRING_RAW_CAPACITY // buffer capacity for C.mdq_to_mallocated_string_raw() )
const TEXT_MAX_LENGTH_FOR_CONVERSION = 100
Max text length that is convertible to a MyQuad value, by From_bytes_raw(), From_bytes() or From_string().
Variables ¶
var G_DECQUAD_MACROS string // for information
Functions ¶
func AppendQuad ¶
AppendQuad appends string representation of decQuad into byte slice. This representation is the BEST TO DISPLAY decQuad, because it shows all numbers having exponent between 0 and -34 (DECQUAD_Pmax), that is, all numbers in the NUMERIC range, without using exponent notation.
All digits of the coefficient are displayed, e.g. 12344567890.123456789000000000000000 If the number must have an exponent because it is too large or too small, we can have 1.4E+201 0E-6176 Infinity
func Append_compressed_bytes ¶
Append_compressed_bytes appends the internal decQuad byte array, in a compressed representation. It is useful for serializing MyQuad to disk, as it often contains a section of bytes full of 0.
func Byteslice2Cstring ¶
Byteslice2Cstring creates a copy of bs in C heap, and returns a pointer to it.
func Byteslice_into_C ¶
Byteslice_into_C creates a byteslice, with p (pointer into C heap) as underlying array. length is string length, not capacity.
func Check_equality_FOR_TEST ¶
Compare compares a with b. returns 1 (greater), 0 (equal), or -1 (less) Never fails.
*** THIS FUNCTION MUST BE USED ONLY FOR TESTS *** In tests, we want to compare not only the value of a and b, but also their exponents. E.g. "12.5" != "12.50"
func Compare ¶
Compare compares a with b. returns 1 (greater), 0 (equal), or -1 (less) Never fails. Nan < -Inf < normal number < +Inf
func From_bytes ¶
From_bytes writes the value of a byte slice ascii text, converted to numeric, into MyQuad. Leading and trailing spaces in value argument are trimmed. Returns error if invalid text.
func From_bytes_raw ¶
From_bytes_raw writes the value of a byte slice ascii text, converted to numeric, into MyQuad. Leading and trailing spaces in value argument are trimmed. Returns error if invalid text.
Argument can be "Inf", "-Inf" or "Nan", and no error code is returned in these cases.
The result number is not constrained by any precision or scale.
func From_bytes_with_implied_p_s ¶
func From_bytes_with_implied_p_s(r *MyQuad, value []byte) (precision uint16, scale uint16, rsql_err *rsql.Error)
From_bytes_with_implied_p_s writes the value of a byte slice ascii text, converted to numeric, into MyQuad. Leading and trailing spaces in value argument are trimmed. Precision and scale implied by the string value are returned (e.g. "123.45" returns <5,2,nil> ). Precision and scale must be valid for NUMERIC type. Else, an error is returned. Returns error if invalid text.
func From_int32 ¶
From_int32 write value into MyQuad.
func From_int32_raw ¶
From_int32 write value into MyQuad. The result number is not constrained by any precision or scale.
func From_int64 ¶
From_int64 write value into MyQuad.
func From_int64_raw ¶
From_int64 write value into MyQuad. The result number is not constrained by any precision or scale.
func From_string ¶
From_string writes the value of a string, converted to numeric, into MyQuad. Leading and trailing spaces in value argument are trimmed. Returns error if invalid text.
func From_string_raw ¶
From_string_raw writes the value of a string, converted to numeric, into MyQuad. Leading and trailing spaces in value argument are trimmed. Returns error if invalid text.
Argument can be "Inf", "-Inf" or "Nan", and no error code is returned in these cases.
The result number is not constrained by any precision or scale.
func From_string_with_implied_p_s ¶
func From_string_with_implied_p_s(r *MyQuad, value string) (precision uint16, scale uint16, rsql_err *rsql.Error)
From_string_with_implied_p_s writes the value of a string, converted to numeric, into MyQuad. Leading and trailing spaces in value argument are trimmed. Precision and scale implied by the string value are returned (e.g. "123.45" returns <5,2,nil> ). Precision and scale must be valid for NUMERIC type. Else, an error is returned. Returns error if invalid text.
func Is_negative ¶
Is_negative checks if argument < 0. If 0 or positive, returns false.
func To_byte_representation ¶
func To_byte_representation(a MyQuad) (res [S_DECQUAD_Bytes]byte)
To_byte_representation returns the internal decQuad byte array.
func To_float64 ¶
To_float64 converts MyQuad value to float64. Returns an error if Inf or Nan or conversion failed.
func To_int32_round ¶
To_int32_round converts MyQuad value to int32. Returns an error if Inf or Nan or conversion failed.
func To_int32_truncate ¶
To_int32_truncate converts MyQuad value to int32. Returns an error if Inf or Nan or conversion failed.
func To_int64_round ¶
To_int64_round converts MyQuad value to int64. Returns an error if Inf or Nan or conversion failed.
func To_int64_truncate ¶
To_int64_truncate converts MyQuad value to int64. Returns an error if Inf or Nan or conversion failed.
func Unary_minus ¶
Types ¶
type MyQuad ¶
type MyQuad struct {
// contains filtered or unexported fields
}
MyQuad is a struct that just contains a C.decQuad value.
func From_byte_representation ¶
func From_byte_representation(a [S_DECQUAD_Bytes]byte) (res MyQuad)
From_byte_representation returns decQuad from byte representation.
func Uncompress_bytes ¶
Uncompress_bytes uncompresses bytes in src into MyQuad. It is the opposite of Append_compressed_bytes().
func (*MyQuad) String_raw ¶
String_raw returns the representation of a decQuad as an integer coefficient with an exponent. E.g. 123456e-2 This function is used for testing, to see exactly the coefficient and exponent stored in the decQuad. IT IS NOT USEFUL FOR NORMAL USE AND SHOULD BE AVOIDED.