maziac/binary-file-viewer

How to read float value?

Maekdzp opened this issue · 5 comments

Hi, thanks to make this amazing tool. But I find it since that there is no way to read a 4-bytes float value. I've tried getNumberValue() and getDecimalValue() which both return integers. Also tried to search 'float' in help document and get nothing. Did I miss something or it just not supported yet?

I have not implemented this.
Simply because I suspect that this would become a huge feature. There are certainly more than 1 floating format to consider.
I didn't require it for my own projects.

But if you want to contribute I'm open to look into a PR.

Well standard way is like integers ? except there are floating point types and decimal types. Othewise not so many formats.

maziac commented

I have implemented the IEEE754 with the function getFloatNumberValue(). You need to read either 4 or 8 bytes for single or double precision.

Please let me know if it works for you.
Here is the vsix:
binary-file-viewer-1.7.4-rc1.vsix.zip

Actually I've wrote a simple float conversion in my parser, but since it's just a local function without any plugin source code change and there was no data validation check or double precision support, I didn't make a contribute. So it's good to see you implemented a better version and I've replaced my function with yours and it worked well. Thanks for the update!

maziac commented

Solved in 1.8.0.