Quantcast
Channel: MSP low-power microcontrollers
Viewing all articles
Browse latest Browse all 62309

Forum Post: RE: conversion of hex data to float inverse

$
0
0
Hi Harish! You could, for example, use a function like this: float hex_to_float( uint8_t * hex_array ); uint8_t float_in_hex[4] = { 0x43, 0xCf, 0x80, 0x00 }; float float_from_hex; ... void main( void ) { ... float_from_hex = hex_to_float( float_in_hex ); ... } float hex_to_float( uint8_t * hex_array ) { float result; uint8_t counter; uint8_t * pointer; pointer = (uint8_t *) &result; for( counter = 0; counter < sizeof( float ); counter++ ) { *(pointer + counter) = *(hex_array + sizeof( float ) - 1 - counter); } return result; } Dennis

Viewing all articles
Browse latest Browse all 62309

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>