|
@@ -155,7 +155,7 @@ UA_StatusCode UA_Float_decodeBinary(UA_ByteString const *src, size_t *offset, UA
|
|
biasedExponent |= (UA_UInt32)(src->data[*offset+3] & 0x7F) << 1; // bits 24-30
|
|
biasedExponent |= (UA_UInt32)(src->data[*offset+3] & 0x7F) << 1; // bits 24-30
|
|
sign = ( src->data[*offset+ 3] & 0x80 ) ? -1.0 : 1.0; // bit 31
|
|
sign = ( src->data[*offset+ 3] & 0x80 ) ? -1.0 : 1.0; // bit 31
|
|
if(biasedExponent >= 127)
|
|
if(biasedExponent >= 127)
|
|
- *dst = (UA_Float)sign * (1 << (biasedExponent-127)) * (1.0 + mantissa / 128.0 );
|
|
|
|
|
|
+ *dst = (UA_Float)sign * (1ULL << (biasedExponent-127)) * (1.0 + mantissa / 128.0 );
|
|
else
|
|
else
|
|
*dst = (UA_Float)sign * 2.0 * (1.0 + mantissa / 128.0 ) / ((UA_Float)(biasedExponent-127));
|
|
*dst = (UA_Float)sign * 2.0 * (1.0 + mantissa / 128.0 ) / ((UA_Float)(biasedExponent-127));
|
|
*offset += 4;
|
|
*offset += 4;
|
|
@@ -171,6 +171,7 @@ UA_TYPE_CALCSIZEBINARY_MEMSIZE(UA_Double)
|
|
// FIXME: Implement NaN, Inf and Zero(s)
|
|
// FIXME: Implement NaN, Inf and Zero(s)
|
|
UA_Byte UA_DOUBLE_ZERO[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
UA_Byte UA_DOUBLE_ZERO[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
UA_StatusCode UA_Double_decodeBinary(UA_ByteString const *src, size_t *offset, UA_Double * dst) {
|
|
UA_StatusCode UA_Double_decodeBinary(UA_ByteString const *src, size_t *offset, UA_Double * dst) {
|
|
|
|
+#include "stdio.h"
|
|
if(*offset + sizeof(UA_Double) > (UA_UInt32)src->length )
|
|
if(*offset + sizeof(UA_Double) > (UA_UInt32)src->length )
|
|
return UA_STATUSCODE_BADDECODINGERROR;
|
|
return UA_STATUSCODE_BADDECODINGERROR;
|
|
UA_Double sign;
|
|
UA_Double sign;
|
|
@@ -189,7 +190,7 @@ UA_StatusCode UA_Double_decodeBinary(UA_ByteString const *src, size_t *offset, U
|
|
biasedExponent |= ((UA_UInt32)(src->data[*offset+7] & 0x7F)) << 4; // bits 56-62
|
|
biasedExponent |= ((UA_UInt32)(src->data[*offset+7] & 0x7F)) << 4; // bits 56-62
|
|
sign = ( src->data[*offset+7] & 0x80 ) ? -1.0 : 1.0; // bit 63
|
|
sign = ( src->data[*offset+7] & 0x80 ) ? -1.0 : 1.0; // bit 63
|
|
if(biasedExponent >= 1023)
|
|
if(biasedExponent >= 1023)
|
|
- *dst = (UA_Double)sign * (1 << (biasedExponent-1023)) * (1.0 + mantissa / 8.0 );
|
|
|
|
|
|
+ *dst = (UA_Double)sign * (1ULL << (biasedExponent-1023)) * (1.0 + mantissa / 8.0 );
|
|
else
|
|
else
|
|
*dst = (UA_Double)sign * 2.0 *
|
|
*dst = (UA_Double)sign * 2.0 *
|
|
(1.0 + mantissa / 8.0 ) / ((UA_Double)(biasedExponent-1023));
|
|
(1.0 + mantissa / 8.0 ) / ((UA_Double)(biasedExponent-1023));
|