XML Schema Datetime and Decimals

## XML Schema Datetime and Decimals XML Schema Datetime and Decimals — XML Schema datetime and arbitrary length decimal number arithmetic. |

## Synopsis

                        rasqal_xsd_date;
    rasqal_xsd_date *   rasqal_new_xsd_date                 (rasqal_world *world,
                                                             const char *date_string);
    void                rasqal_free_xsd_date                (rasqal_xsd_date *d);
    char *              rasqal_xsd_date_to_counted_string   (const rasqal_xsd_date *date,
                                                             size_t *len_p);
    char *              rasqal_xsd_date_to_string           (const rasqal_xsd_date *d);
    int                 rasqal_xsd_date_equals              (const rasqal_xsd_date *d1,
                                                             const rasqal_xsd_date *d2,
                                                             int *incomparible_p);
    int                 rasqal_xsd_date_compare             (const rasqal_xsd_date *d1,
                                                             const rasqal_xsd_date *d2,
                                                             int *incomparible_p);
                        rasqal_xsd_datetime;
    #define             RASQAL_XSD_DATETIME_NO_TZ
    rasqal_xsd_datetime * rasqal_new_xsd_datetime           (rasqal_world *world,
                                                             const char *datetime_string);
    rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_timeval
                                                            (rasqal_world *world,
                                                             struct timeval *tv);
    rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_unixtime
                                                            (rasqal_world *world,
                                                             time_t secs);
    rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_xsd_date
                                                            (rasqal_world *world,
                                                             rasqal_xsd_date *date);
    void                rasqal_free_xsd_datetime            (rasqal_xsd_datetime *dt);
    int                 rasqal_xsd_datetime_compare         (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2);
    int                 rasqal_xsd_datetime_compare2        (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2,
                                                             int *incomparible_p);
    int                 rasqal_xsd_datetime_equals          (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2);
    int                 rasqal_xsd_datetime_equals2         (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2,
                                                             int *incomparible_p);
    struct timeval *    rasqal_xsd_datetime_get_as_timeval  (rasqal_xsd_datetime *dt);
    time_t              rasqal_xsd_datetime_get_as_unixtime (rasqal_xsd_datetime *dt);
    rasqal_xsd_decimal * rasqal_xsd_datetime_get_seconds_as_decimal
                                                            (rasqal_world *world,
                                                             rasqal_xsd_datetime *dt);
    char *              rasqal_xsd_datetime_get_timezone_as_counted_string
                                                            (rasqal_xsd_datetime *dt,
                                                             size_t *len_p);
    char *              rasqal_xsd_datetime_get_tz_as_counted_string
                                                            (rasqal_xsd_datetime *dt,
                                                             size_t *len_p);
    int                 rasqal_xsd_datetime_set_from_timeval
                                                            (rasqal_xsd_datetime *dt,
                                                             struct timeval *tv);
    int                 rasqal_xsd_datetime_set_from_unixtime
                                                            (rasqal_xsd_datetime *dt,
                                                             time_t clock);
    char *              rasqal_xsd_datetime_to_counted_string
                                                            (const rasqal_xsd_datetime *dt,
                                                             size_t *len_p);
    char *              rasqal_xsd_datetime_to_string       (const rasqal_xsd_datetime *dt);
    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_abs              (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);
    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_ceil             (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);
    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);
    int                 rasqal_xsd_decimal_floor            (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);
    double              rasqal_xsd_decimal_get_double       (rasqal_xsd_decimal *dec);
    long                rasqal_xsd_decimal_get_long         (rasqal_xsd_decimal *dec,
                                                             int *error_p);
    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_negate           (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);
    int                 rasqal_xsd_decimal_print            (rasqal_xsd_decimal *dec,
                                                             FILE *stream);
    int                 rasqal_xsd_decimal_round            (rasqal_xsd_decimal *result,
                                                             rasqal_xsd_decimal *a);
    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);

## Description

Classes for providing XSD datatypes for Datetimes plus Decimals with arbitrary length floating point decimals and standard operators on the Decimals suitable for SPARQL.

## Details

### rasqal_xsd_date

    typedef struct {
      signed int year;
      /* the following fields are integer values not characters */
      unsigned char month;
      unsigned char day;
      signed short timezone_minutes;
      time_t time_on_timeline;
      char have_tz;
    } rasqal_xsd_date;

XML schema date datatype (xsd:date)

Examples of timezone fields: "2010-01-02" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N' "2010-01-02Z" : timezone_minutes 0, have_tz 'Z' "2010-01-02+00:00" : timezone_minutes 0, have_tz 'Y' "2010-01-02-01:00" : timezone_minutes -60, have_tz 'Y'

signed int `year`; | year
unsigned char `month`; | month 1-12
unsigned char `day`; | 1-31
signed short `timezone_minutes`; | minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime.
time_t `time_on_timeline`; | time on timeline of first instant of date in timezone
char `have_tz`; | timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in `timezone_minutes`, 'N' if there is no timezone

### rasqal_new_xsd_date ()

    rasqal_xsd_date *   rasqal_new_xsd_date                 (rasqal_world *world,
                                                             const char *date_string);

Constructor - make a new XSD date object from a string

`world` : | world object
`date_string` : | XSD date string
Returns : | new datetime or NULL on failure

### rasqal_free_xsd_date ()

    void                rasqal_free_xsd_date                (rasqal_xsd_date *d);

Destroy XSD date object.

`d` : | date object

### rasqal_xsd_date_to_counted_string ()

    char *              rasqal_xsd_date_to_counted_string   (const rasqal_xsd_date *date,
                                                             size_t *len_p);

Convert a rasqal_xsd_date struct to a xsd:date lexical form string.

Caller should `rasqal_free_memory()` the returned string.

See http://www.w3.org/TR/xmlschema-2/date-canonical-representation

`date` : | date struct
`len_p` : | output length (or NULL)
Returns : | lexical form string or NULL on failure.

### rasqal_xsd_date_to_string ()

    char *              rasqal_xsd_date_to_string           (const rasqal_xsd_date *d);

Convert a rasqal_xsd_date struct to a xsd:date lexical form string.

Caller should `rasqal_free_memory()` the returned string.

`d` : | date struct
Returns : | lexical form string or NULL on failure.

### rasqal_xsd_date_equals ()

    int                 rasqal_xsd_date_equals              (const rasqal_xsd_date *d1,
                                                             const rasqal_xsd_date *d2,
                                                             int *incomparible_p);

Compare two XSD dates for equality.

`d1` : | first XSD date
`d2` : | second XSD date
`incomparible_p` : | address to store incomparable flag (or NULL)
Returns : | non-0 if equal.

### rasqal_xsd_date_compare ()

    int                 rasqal_xsd_date_compare             (const rasqal_xsd_date *d1,
                                                             const rasqal_xsd_date *d2,
                                                             int *incomparible_p);

Compare two XSD dates

If the only one of the two dates have timezones, the results may be incomparible and that will return >0 and set the value of the int point to by `incomparible_p` to non-0

`d1` : | first XSD date
`d2` : | second XSD date
`incomparible_p` : | address to store incomparable flag (or NULL)
Returns : | <0 if `d1` is less than `d2`, 0 if equal, >0 otherwise

### rasqal_xsd_datetime

    typedef struct {
      signed int year;
      unsigned char month;
      unsigned char day;
      /* the following fields are integer values not characters */
      signed char hour;
      signed char minute;
      signed char second;
      signed int microseconds;
      signed short timezone_minutes;
      time_t time_on_timeline;
      char have_tz;
    } rasqal_xsd_datetime;

XML Schema dateTime datatype (xsd:dateTime)

Signed types are required for normalization process where a value can be negative temporarily.

Examples of timezone fields: "2010-01-02T01:02:03" : timezone_minutes RASQAL_XSD_DATETIME_NO_TZ, have_tz 'N' "2010-01-02T01:02:03Z" : timezone_minutes 0, have_tz 'Z' "2010-01-02T01:02:03+00:00" : timezone_minutes 0, have_tz 'Y' "2010-01-02T01:02:03-01:00" : timezone_minutes -60, have_tz 'Y'

signed int `year`; | year
unsigned char `month`; | month 1-12
unsigned char `day`; | 1-31
signed char `hour`; | hour 0-23
signed char `minute`; | minute 0-59
signed char `second`; | second 0-60 (yes 60 is allowed for leap seconds)
signed int `microseconds`; | microseconds
signed short `timezone_minutes`; | minutes +/- against UTC or RASQAL_XSD_DATETIME_NO_TZ if there is no timezone in the dateTime.
time_t `time_on_timeline`; | time on timeline
char `have_tz`; | timezone flag: 'Z' if Zulu, 'Y' if has other timezone offset in `timezone_minutes`, 'N' if there is no timezone

### RASQAL_XSD_DATETIME_NO_TZ

    #define RASQAL_XSD_DATETIME_NO_TZ (9999)

Sentinel XSD Decimal timezone value indicating no timezone is present.

### rasqal_new_xsd_datetime ()

    rasqal_xsd_datetime * rasqal_new_xsd_datetime           (rasqal_world *world,
                                                             const char *datetime_string);

Constructor - make a new XSD datetime object from a string

`world` : | world object
`datetime_string` : | XSD Datetime string
Returns : | new datetime or NULL on failure

### rasqal_new_xsd_datetime_from_timeval ()

    rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_timeval
                                                            (rasqal_world *world,
                                                             struct timeval *tv);

Constructor - make a new XSD datetime object from a timeval

`world` : | world object
`tv` : | pointer to struct timeval
Returns : | new datetime or NULL on failure

### rasqal_new_xsd_datetime_from_unixtime ()

    rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_unixtime
                                                            (rasqal_world *world,
                                                             time_t secs);

Constructor - make a new XSD datetime object from unixtime seconds

`world` : | world object
`secs` : | unixtime
Returns : | new datetime or NULL on failure

### rasqal_new_xsd_datetime_from_xsd_date ()

    rasqal_xsd_datetime * rasqal_new_xsd_datetime_from_xsd_date
                                                            (rasqal_world *world,
                                                             rasqal_xsd_date *date);

Constructor - make a new XSD datetime object from an XSD date

`world` : | world object
`date` : | pointer to XSD date
Returns : | new datetime or NULL on failure

### rasqal_free_xsd_datetime ()

    void                rasqal_free_xsd_datetime            (rasqal_xsd_datetime *dt);

Destroy XSD datetime object.

`dt` : | datetime object

### rasqal_xsd_datetime_compare ()

    int                 rasqal_xsd_datetime_compare         (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2);

Compare two XSD dateTimes

`Deprecated` for `rasqal_xsd_datetime_compare2()` which can return the incomparible result.

`dt1` : | first XSD dateTime
`dt2` : | second XSD dateTime
Returns : | <0 if `dt1` is less than `dt2`, 0 if equal, >0 otherwise

### rasqal_xsd_datetime_compare2 ()

    int                 rasqal_xsd_datetime_compare2        (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2,
                                                             int *incomparible_p);

Compare two XSD dateTimes

If the only one of the two dateTimes have timezones, the results may be incomparible and that will return >0 and set the value of the int point to by `incomparible_p` to non-0

`dt1` : | first XSD dateTime
`dt2` : | second XSD dateTime
`incomparible_p` : | address to store incomparable flag (or NULL)
Returns : | <0 if `dt1` is less than `dt2`, 0 if equal, >0 otherwise

### rasqal_xsd_datetime_equals ()

    int                 rasqal_xsd_datetime_equals          (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2);

Compare two XSD dateTimes for equality.

`Deprecated`: for rasqal_xsd_datetime_equals2 that returns incomparibility.

`dt1` : | first XSD dateTime
`dt2` : | second XSD dateTime
Returns : | non-0 if equal.

### rasqal_xsd_datetime_equals2 ()

    int                 rasqal_xsd_datetime_equals2         (const rasqal_xsd_datetime *dt1,
                                                             const rasqal_xsd_datetime *dt2,
                                                             int *incomparible_p);

Compare two XSD dateTimes for equality.

`dt1` : | first XSD dateTime
`dt2` : | second XSD dateTime
`incomparible_p` : | address to store incomparable flag (or NULL)
Returns : | non-0 if equal.

### rasqal_xsd_datetime_get_as_timeval ()

    struct timeval *    rasqal_xsd_datetime_get_as_timeval  (rasqal_xsd_datetime *dt);

Get a datetime as struct timeval

The returned timeval must be freed by the caller such as using `rasqal_free_memory()`.

`dt` : | datetime
Returns : | pointer to a new timeval structure or NULL on failure

### rasqal_xsd_datetime_get_as_unixtime ()

    time_t              rasqal_xsd_datetime_get_as_unixtime (rasqal_xsd_datetime *dt);

Get a datetime as unix seconds

`dt` : | datetime
Returns : | unix seconds or 0 if `dt` is NULL

### rasqal_xsd_datetime_get_seconds_as_decimal ()

    rasqal_xsd_decimal * rasqal_xsd_datetime_get_seconds_as_decimal
                                                            (rasqal_world *world,
                                                             rasqal_xsd_datetime *dt);

Get the seconds component of a dateTime as a decimal

`world` : | world object
`dt` : | XSD dateTime
Returns : | decimal object or NULL on failure

### rasqal_xsd_datetime_get_timezone_as_counted_string ()

    char *              rasqal_xsd_datetime_get_timezone_as_counted_string
                                                            (rasqal_xsd_datetime *dt,
                                                             size_t *len_p);

Get the timezone of a datetime as a duration format string with optional length count

The returned string is owned by the caller and must be freed by `rasqal_free_memory()`.

`dt` : | datetime
`len_p` : | pointer to store returned string length
Returns : | pointer to a new string or NULL on failure

### rasqal_xsd_datetime_get_tz_as_counted_string ()

    char *              rasqal_xsd_datetime_get_tz_as_counted_string
                                                            (rasqal_xsd_datetime *dt,
                                                             size_t *len_p);

Get the timezone of a datetime as a timezone string

The returned string is owned by the caller and must be freed by `rasqal_free_memory()`.

`dt` : | datetime
`len_p` : | pointer to store returned string length
Returns : | pointer to a new string or NULL on failure

### rasqal_xsd_datetime_set_from_timeval ()

    int                 rasqal_xsd_datetime_set_from_timeval
                                                            (rasqal_xsd_datetime *dt,
                                                             struct timeval *tv);

Set an XSD dateTime from a struct timeval pointer

`dt` : | datetime
`tv` : | timeval
Returns : | non-0 on failure

### rasqal_xsd_datetime_set_from_unixtime ()

    int                 rasqal_xsd_datetime_set_from_unixtime
                                                            (rasqal_xsd_datetime *dt,
                                                             time_t clock);

Set an XSD dateTime from unixtime seconds

`dt` : | date time
`clock` : | unix time in seconds
Returns : | non-0 on failure

### rasqal_xsd_datetime_to_counted_string ()

    char *              rasqal_xsd_datetime_to_counted_string
                                                            (const rasqal_xsd_datetime *dt,
                                                             size_t *len_p);

Convert a rasqal_xsd_datetime struct to a xsd:dateTime lexical form counted string.

Caller should `rasqal_free_memory()` the returned string.

See http://www.w3.org/TR/xmlschema-2/dateTime-canonical-representation

`dt` : | datetime struct
`len_p` : | output length (or NULL)
Returns : | lexical form string or NULL on failure.

### rasqal_xsd_datetime_to_string ()

    char *              rasqal_xsd_datetime_to_string       (const rasqal_xsd_datetime *dt);

Convert a rasqal_xsd_datetime struct to a xsd:dateTime lexical form string.

Caller should `rasqal_free_memory()` the returned string.

`dt` : | datetime struct
Returns : | lexical form string or NULL on failure.

### 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_abs ()

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

Return the absolute value of an XSD Decimal

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

### 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_ceil ()

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

Return the number with no fractional part closes to argument for an XSD Decimal

`result` : | result variable
`a` : | argment decimal
Returns : | non-0 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_floor ()

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

Return the number with no fractional part closes to argument for an XSD Decimal

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

### 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_get_long ()

    long                rasqal_xsd_decimal_get_long         (rasqal_xsd_decimal *dec,
                                                             int *error_p);

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

`dec` : | XSD Decimal
`error_p` : | pointer to error flag
Returns : | long value or 0 on failure and *error_p is non-0

### 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_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

### rasqal_xsd_decimal_print ()

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

Print an XSD Decimal to a stream

`dec` : | XSD Decimal object
`stream` : | FILE* handle to print to
Returns : | non-0 on failure

### rasqal_xsd_decimal_round ()

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

Return the number with no fractional part closes to argument for an XSD Decimal

`result` : | result variable
`a` : | argment decimal
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
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