quad

package
v0.0.0-...-91c5940 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2017 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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()
)
View Source
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

View Source
var G_DECQUAD_MACROS string // for information

Functions

func Abs

func Abs(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error

func Add

func Add(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error

func AppendQuad

func AppendQuad(dst []byte, a *MyQuad) []byte

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

func Append_compressed_bytes(dest []byte, a MyQuad) (dest_modified []byte, length uint16)

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

func Byteslice2Cstring(bs []byte) *C.char

Byteslice2Cstring creates a copy of bs in C heap, and returns a pointer to it.

func Byteslice_into_C

func Byteslice_into_C(p *C.char, length C.size_t) []byte

Byteslice_into_C creates a byteslice, with p (pointer into C heap) as underlying array. length is string length, not capacity.

func Ceiling

func Ceiling(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error

func Check_equality_FOR_TEST

func Check_equality_FOR_TEST(a *MyQuad, b *MyQuad) bool

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

func Compare(a *MyQuad, b *MyQuad) int

Compare compares a with b. returns 1 (greater), 0 (equal), or -1 (less) Never fails. Nan < -Inf < normal number < +Inf

func Copy

func Copy(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error

func Divide

func Divide(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error

func Floor

func Floor(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error

func From_bytes

func From_bytes(r *MyQuad, precision uint16, scale uint16, value []byte) *rsql.Error

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

func From_bytes_raw(r *MyQuad, value []byte) *rsql.Error

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

func From_int32(r *MyQuad, precision uint16, scale uint16, value int32) *rsql.Error

From_int32 write value into MyQuad.

func From_int32_raw

func From_int32_raw(r *MyQuad, value int32)

From_int32 write value into MyQuad. The result number is not constrained by any precision or scale.

func From_int64

func From_int64(r *MyQuad, precision uint16, scale uint16, value int64) *rsql.Error

From_int64 write value into MyQuad.

func From_int64_raw

func From_int64_raw(r *MyQuad, value int64)

From_int64 write value into MyQuad. The result number is not constrained by any precision or scale.

func From_string

func From_string(r *MyQuad, precision uint16, scale uint16, value string) *rsql.Error

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

func From_string_raw(r *MyQuad, value string) *rsql.Error

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 Hash

func Hash(a *MyQuad) uint32

func Is_negative

func Is_negative(r *MyQuad) bool

Is_negative checks if argument < 0. If 0 or positive, returns false.

func Is_zero

func Is_zero(r *MyQuad) bool

Is_zero checks if argument == 0

func Multiply

func Multiply(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error

func Plain_zero

func Plain_zero(r *MyQuad)

Plain_zero sets argument to 0.

func Power

func Power(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b float64) *rsql.Error

func Round

func Round(r *MyQuad, precision uint16, scale uint16, a *MyQuad, a_precision uint16, a_scale uint16, b int32, truncate_flag uint8) *rsql.Error

func Round_for_formatting

func Round_for_formatting(r *MyQuad, a *MyQuad, b int32) *rsql.Error

func Sign

func Sign(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error

func Subtract

func Subtract(r *MyQuad, precision uint16, scale uint16, a *MyQuad, b *MyQuad) *rsql.Error

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

func To_float64(a *MyQuad) (float64, *rsql.Error)

To_float64 converts MyQuad value to float64. Returns an error if Inf or Nan or conversion failed.

func To_int32_round

func To_int32_round(a *MyQuad) (int32, *rsql.Error)

To_int32_round converts MyQuad value to int32. Returns an error if Inf or Nan or conversion failed.

func To_int32_truncate

func To_int32_truncate(a *MyQuad) (int32, *rsql.Error)

To_int32_truncate converts MyQuad value to int32. Returns an error if Inf or Nan or conversion failed.

func To_int64_round

func To_int64_round(a *MyQuad) (int64, *rsql.Error)

To_int64_round converts MyQuad value to int64. Returns an error if Inf or Nan or conversion failed.

func To_int64_truncate

func To_int64_truncate(a *MyQuad) (int64, *rsql.Error)

To_int64_truncate converts MyQuad value to int64. Returns an error if Inf or Nan or conversion failed.

func Unary_minus

func Unary_minus(r *MyQuad, precision uint16, scale uint16, a *MyQuad) *rsql.Error

func Zero

func Zero(r *MyQuad, precision uint16, scale uint16)

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

func Uncompress_bytes(src []byte) (res MyQuad)

Uncompress_bytes uncompresses bytes in src into MyQuad. It is the opposite of Append_compressed_bytes().

func (*MyQuad) String

func (a *MyQuad) String() string

String is the preferred way to display a decQuad number.

func (*MyQuad) String_raw

func (a *MyQuad) String_raw() string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL