2 * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
5 #ifndef ASN_TYPE_REAL_H
6 #define ASN_TYPE_REAL_H
8 #include <asn_application.h>
9 #include <asn_codecs_prim.h>
15 typedef ASN__PRIMITIVE_TYPE_t REAL_t;
17 extern asn_TYPE_descriptor_t asn_DEF_REAL;
18 extern asn_TYPE_operation_t asn_OP_REAL;
20 asn_struct_print_f REAL_print;
21 asn_struct_compare_f REAL_compare;
22 oer_type_decoder_f REAL_decode_oer;
23 oer_type_encoder_f REAL_encode_oer;
24 per_type_decoder_f REAL_decode_uper;
25 per_type_encoder_f REAL_encode_uper;
26 per_type_decoder_f REAL_decode_aper;
27 per_type_encoder_f REAL_encode_aper;
28 xer_type_decoder_f REAL_decode_xer;
29 xer_type_encoder_f REAL_encode_xer;
30 asn_random_fill_f REAL_random_fill;
32 #define REAL_free ASN__PRIMITIVE_TYPE_free,
33 #define REAL_constraint asn_generic_no_constraint
34 #define REAL_decode_ber ber_decode_primitive
35 #define REAL_encode_der der_encode_primitive
37 /***********************************
38 * Some handy conversion routines. *
39 ***********************************/
41 ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key);
44 * Convert between native double type and REAL representation (DER).
46 * 0: Value converted successfully
47 * -1: An error occured while converting the value: invalid format.
49 int asn_REAL2double(const REAL_t *real_ptr, double *d);
50 int asn_double2REAL(REAL_t *real_ptr, double d);
53 * Downcast double to float while checking that no overflow occurs.
54 * This allows stricter control of the input data.
56 * 0: The conversion was successful (perhaps with a loss of precision)
57 * -1: The conversion created overflow into infinities.
58 * The (outcome) is ALWAYS set to a value you'd expect from the
59 * standard silent float to double conversion behavior.
61 int asn_double2float(double d, float *outcome);
67 #endif /* ASN_TYPE_REAL_H */