简体   繁体   中英

convert floating point number to RGB or HEX

I have the following floating point number 8.8489784e-39 extracted from the PCD DATA FORMAT which represents the RGB value of one point of the point cloud.

I have to convert this to either HEX directly or to Int->RGB or whichever way. I searched the web but couldn't put anything together so far as my experience with floating-point arithmetic in javascript is fairly limited.

So I'm guessing that's one byte each of red, green, and blue, stored in the first three bytes of a 4-byte word, which is then inexplicably interpreted as a float instead of an int.

If that's the case, then 8.8489784e-39f represents the RGB triple (90,91,96) [decimal] or #5a5b60 in web hex.

But doing that conversion in Javascript will not be easy. You could look at the conversion function decodeFloat defined here , or perhaps you can start with the answer to this question .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM