From mboxrd@z Thu Jan 1 00:00:00 1970 From: greg@kroah.com (Greg KH) Date: Tue, 22 Nov 2016 17:39:59 +0100 Subject: IEEE-754 Float to int In-Reply-To: References: Message-ID: <20161122163959.GB2919@kroah.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org On Tue, Nov 22, 2016 at 04:05:18PM +0000, Lucas Tanure wrote: > Hi,? > > At some point my hardware gives me a 32bit?IEEE-754 float, like this : > > > regmap_read(device->regmap, ADDR0, &temp); > > value = temp << 16; > > regmap_read(device->regmap,?ADDR1, &temp); > > value |= temp; > > > So, value has a 32bit float now, and I would like to print just the integer > part, like : > Read 26.92387 --> Print 26.? > Simple, no float operations.? > > How I can do it ? Just print the upper 16 bits shifted right by 16 bits. But why would you want to print the value anyway? Who would use it? thanks, greg k-h