Skip to content
Browse files

Handle floating-point numbers (closes #28)

Mostly I just want make this last test green. Shelling out to awk slows things
down, unfortunately, but at least at this point forward we can just improve the
performance. I still suspect we can simplify the whole thing with a smarter
rewrite and speed things up to boot.
  • Loading branch information...
1 parent 2781a52 commit 48f2b2340cd1c1a72beef12383233aed3908b952 @holman committed
Showing with 3 additions and 3 deletions.
  1. +2 −2 spark
  2. +1 −1 spark-test.sh
View
4 spark
@@ -69,7 +69,7 @@ setup_array() {
sort_max()
{
last=${#sorted[@]}
- echo ${sorted[$last - 1]}
+ echo $(echo ${sorted[$last - 1]} | awk '{printf "%.0f",$1}')
}
# The minimum value of the sorted array. In other words, the first value.
@@ -100,7 +100,7 @@ print_tick()
for (( i = 0 ; i < ${#ticks[@]} ; i++ ))
do
- number=$1
+ number=$(echo $1 | awk '{printf "%.0f",$1}')
less_than=$(( $i * $tier + sort_min + $tier ))
greater_than=$(( ($i - 1) * $tier + sort_min + $tier ))
result=$(( $number <= $less_than && $number >= $greater_than ))
View
2 spark-test.sh
@@ -35,7 +35,7 @@ it_handles_decimals() {
data="5.5,20"
graph="$($spark $data)"
- test $graph = '▂▇'
+ test $graph = '▃█'
}
it_charts_100_lt_300() {

0 comments on commit 48f2b23

Please sign in to comment.
Something went wrong with that request. Please try again.