Line data Source code
1 : /** 2 : * @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved. 3 : * 4 : * @file float2Buf.c 5 : * @author Jacob.Garrison 6 : * 7 : * @date Mar 2, 2021 8 : * 9 : */ 10 : 11 : #include "sgUtil.h" 12 : 13 : /* 14 : * Documented in the header file. 15 : */ 16 36 : void float2Buf(uint8_t *bufferPos, float value) 17 36 : { 18 36 : const uint16_t FLOAT_SIZE = 4; 19 : 20 36 : union 21 : { 22 : float val; 23 36 : unsigned char bytes[FLOAT_SIZE]; 24 36 : } conversion; 25 : 26 36 : conversion.val = value; 27 : 28 180 : for (int i = 0; i < FLOAT_SIZE; ++i) 29 : { 30 144 : bufferPos[i] = conversion.bytes[i]; 31 : } 32 36 : }