holman / spark

▁▂▃▅▂▇ in your shell.

Home Page:http://zachholman.com/spark/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Floating Values

seekshreyas opened this issue · comments

@holman : This is a great utility script. Was wondering does it support floating numbers?

I tried few outputs, and it seems the floating numbers are rounded down.

And the scale seems a little off too (refer the first output spark 1.5 3 3.5

Reference:

$ spark 1.5 3 3.5
▁██
Shreyas at Jarvis in ~
$ spark 1.5 3 10
▁▂█
Shreyas at Jarvis in ~
$ spark 1.5 3 2 4 2
▁▅▃█▃
Shreyas at Jarvis in ~
$ spark 1 3 2 4 2
▁▅▃█▃
Shreyas at Jarvis in ~
$ spark 1 3 2 4.9 2
▁▅▃█▃

It should be okay with floats after #28... maybe there are some edge cases, however.

Look at the comments I made in line 39. Floats get their fractional part cut off because there's no portable way of reading them and bash does only work with integers anyway.

So my advice would be to simply multiply the input values to become integers.

@holman @markusfisch : Thanx. Will do.