Skip to content

Commit

Permalink
Handle floating-point numbers (closes holman#28)
Browse files Browse the repository at this point in the history
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
holman committed Nov 16, 2011
1 parent 2781a52 commit 48f2b23
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions spark
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 ))
Expand Down
2 changes: 1 addition & 1 deletion spark-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ it_handles_decimals() {
data="5.5,20"
graph="$($spark $data)"

test $graph = '▂▇'
test $graph = '▃█'
}

it_charts_100_lt_300() {
Expand Down

0 comments on commit 48f2b23

Please sign in to comment.