Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ieee754.hpp Source File

ieee754.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Namespace.hpp>
00008 
00009 namespace ARDUINOJSON_NAMESPACE {
00010 
00011 inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) {
00012   f[0] = uint8_t((d[0] & 0xC0) | (d[0] << 3 & 0x3f) | (d[1] >> 5));
00013   f[1] = uint8_t((d[1] << 3) | (d[2] >> 5));
00014   f[2] = uint8_t((d[2] << 3) | (d[3] >> 5));
00015   f[3] = uint8_t((d[3] << 3) | (d[4] >> 5));
00016 }
00017 
00018 }  // namespace ARDUINOJSON_NAMESPACE