## XML Schema Decimals XML Schema Decimals — XML Schema decimal number arithmetic. |

## Synopsis

    void                rasqal_free_xsd_decimal             (rasqal_xsd_decimal *dec);
    rasqal_xsd_decimal* rasqal_new_xsd_decimal              (rasqal_world *world);
    typedef             rasqal_xsd_decimal;
    int                 rasqal_xsd_decimal_add              (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);
    char*               rasqal_xsd_decimal_as_counted_string
                                                            (rasqal_xsd_decimal *dec,
                                                             size_t *len_p);
    char*               rasqal_xsd_decimal_as_string        (rasqal_xsd_decimal *dec);
    int                 rasqal_xsd_decimal_compare          (rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);
    int                 rasqal_xsd_decimal_divide           (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);
    int                 rasqal_xsd_decimal_equals           (rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);
    double              rasqal_xsd_decimal_get_double       (rasqal_xsd_decimal *dec);
    int                 rasqal_xsd_decimal_is_zero          (rasqal_xsd_decimal *d);
    int                 rasqal_xsd_decimal_multiply         (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);
    int                 rasqal_xsd_decimal_print            (rasqal_xsd_decimal *dec,
                                                             FILE *stream);
    int                 rasqal_xsd_decimal_set_double       (rasqal_xsd_decimal *dec,
                                                             double d);
    int                 rasqal_xsd_decimal_set_long         (rasqal_xsd_decimal *dec,
                                                             long l Param2);
    int                 rasqal_xsd_decimal_set_string       (rasqal_xsd_decimal *dec,
                                                             const char *string);
    int                 rasqal_xsd_decimal_subtract         (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);
    int                 rasqal_xsd_decimal_negate           (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);

## Description

A class for providing XSD Decimals with arbitrary length floating point decimals.

## Details

### rasqal_free_xsd_decimal ()

    void                rasqal_free_xsd_decimal             (rasqal_xsd_decimal *dec);

Destroy XSD Decimal object.

`dec` : | Decimal object

### rasqal_new_xsd_decimal ()

    rasqal_xsd_decimal* rasqal_new_xsd_decimal              (rasqal_world *world);

Create a new XSD Decimal object.

`world` : | rasqal world object
Returns : | new xsd:decimal object or NULL on failure.

### rasqal_xsd_decimal

    typedef struct rasqal_xsd_decimal_s rasqal_xsd_decimal;

Rasqal XSD Decimal class.

### rasqal_xsd_decimal_add ()

    int                 rasqal_xsd_decimal_add              (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);

Add two XSD Decimals and store in result XSD Decimal

`result` : | result variable
`a` : | argment decimal 1
`b` : | argument decimal 2
Returns : | non-0 on failure

### rasqal_xsd_decimal_as_counted_string ()

    char*               rasqal_xsd_decimal_as_counted_string
                                                            (rasqal_xsd_decimal *dec,
                                                             size_t *len_p);

Get an XSD Decimal as a string lexical form with optional length.

The returned string is shared and owned by the `dec` object and must be copied. If `len_p` is not NULL, the length of the returned string is stored.

`dec` : | XSD Decimal
`len_p` : | pointer to length variable (or NULL)
Returns : | lexical form string or NULL on failure.

### rasqal_xsd_decimal_as_string ()

    char*               rasqal_xsd_decimal_as_string        (rasqal_xsd_decimal *dec);

Get an XSD Decimal as a string lexical form.

The returned string is shared and owned by the `dec` object and must be copied.

`dec` : | XSD Decimal
Returns : | lexical form string or NULL on failure.

### rasqal_xsd_decimal_compare ()

    int                 rasqal_xsd_decimal_compare          (rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);

Compare two XSD Decimals

`a` : | first XSD decimal
`b` : | second XSD decimal
Returns : | <0 if `a` is less than `b`, 0 if equal, >1 otherwise

### rasqal_xsd_decimal_divide ()

    int                 rasqal_xsd_decimal_divide           (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);

Divide two XSD Decimals and store in result XSD Decimal

If the divisor `b` is 0, failure is returned

`result` : | result variable
`a` : | argment decimal 1
`b` : | argument decimal 2
Returns : | non-0 on failure

### rasqal_xsd_decimal_equals ()

    int                 rasqal_xsd_decimal_equals           (rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);

Compare two XSD Decimals for equality.

`a` : | first XSD Decimal
`b` : | second XSD Decimal
Returns : | non-0 if equal.

### rasqal_xsd_decimal_get_double ()

    double              rasqal_xsd_decimal_get_double       (rasqal_xsd_decimal *dec);

Get an XSD Decimal as a double (may lose precision)

`dec` : | XSD Decimal
Returns : | double value.

### rasqal_xsd_decimal_is_zero ()

    int                 rasqal_xsd_decimal_is_zero          (rasqal_xsd_decimal *d);

Test if an XSD decimal is zero.

`d` : | decimal
Returns : | non-0 if decimal is zero

### rasqal_xsd_decimal_multiply ()

    int                 rasqal_xsd_decimal_multiply         (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);

Multiply two XSD Decimals and store in result XSD Decimal

`result` : | result variable
`a` : | argment decimal 1
`b` : | argument decimal 2
Returns : | non-0 on failure

### rasqal_xsd_decimal_print ()

    int                 rasqal_xsd_decimal_print            (rasqal_xsd_decimal *dec,
                                                             FILE *stream);

Write an XSD Decimal to a FILE* stream

`dec` : | XSD Decimal
`stream` : | FILE* stream
Returns : | non-0 on failure

### rasqal_xsd_decimal_set_double ()

    int                 rasqal_xsd_decimal_set_double       (rasqal_xsd_decimal *dec,
                                                             double d);

Set an XSD Decimal value from a double.

`dec` : | XSD Decimal
`d` : | double
Returns : | non-0 on failure

### rasqal_xsd_decimal_set_long ()

    int                 rasqal_xsd_decimal_set_long         (rasqal_xsd_decimal *dec,
                                                             long l Param2);

Set an XSD Decimal value from a long.

`dec` : | XSD Decimal
`Param2` : |
Returns : | non-0 on failure

### rasqal_xsd_decimal_set_string ()

    int                 rasqal_xsd_decimal_set_string       (rasqal_xsd_decimal *dec,
                                                             const char *string);

Set an XSD Decimal value from a string lexical form

`dec` : | XSD Decimal
`string` : | lexical form
Returns : | non-0 on failure

### rasqal_xsd_decimal_subtract ()

    int                 rasqal_xsd_decimal_subtract         (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a,
                                                             rasqal_xsd_decimal *b);

Subtract two XSD Decimals and store in result XSD Decimal

`result` : | result variable
`a` : | argment decimal 1
`b` : | argument decimal 2
Returns : | non-0 on failure

### rasqal_xsd_decimal_negate ()

    int                 rasqal_xsd_decimal_negate           (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);

Negate an XSD Decimal

`result` : | result variable
`a` : | argment decimal
Returns : | non-0 on failure