rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef ASN_TYPE_REAL_H |
| 6 | #define ASN_TYPE_REAL_H |
| 7 | |
| 8 | #include <asn_application.h> |
| 9 | #include <asn_codecs_prim.h> |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | typedef ASN__PRIMITIVE_TYPE_t REAL_t; |
| 16 | |
| 17 | extern asn_TYPE_descriptor_t asn_DEF_REAL; |
| 18 | extern asn_TYPE_operation_t asn_OP_REAL; |
| 19 | |
| 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; |
| 31 | |
| 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 |
| 36 | |
| 37 | /*********************************** |
| 38 | * Some handy conversion routines. * |
| 39 | ***********************************/ |
| 40 | |
| 41 | ssize_t REAL__dump(double d, int canonical, asn_app_consume_bytes_f *cb, void *app_key); |
| 42 | |
| 43 | /* |
| 44 | * Convert between native double type and REAL representation (DER). |
| 45 | * RETURN VALUES: |
| 46 | * 0: Value converted successfully |
| 47 | * -1: An error occured while converting the value: invalid format. |
| 48 | */ |
| 49 | int asn_REAL2double(const REAL_t *real_ptr, double *d); |
| 50 | int asn_double2REAL(REAL_t *real_ptr, double d); |
| 51 | |
| 52 | /* |
| 53 | * Downcast double to float while checking that no overflow occurs. |
| 54 | * This allows stricter control of the input data. |
| 55 | * RETURN VALUES: |
| 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. |
| 60 | */ |
| 61 | int asn_double2float(double d, float *outcome); |
| 62 | |
| 63 | #ifdef __cplusplus |
| 64 | } |
| 65 | #endif |
| 66 | |
| 67 | #endif /* ASN_TYPE_REAL_H */ |