Skip to content

Commit

Permalink
Negative whole dollar rounding fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
blynn committed Apr 12, 2016
1 parent 5344f15 commit 5afbc57
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tacky/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
${NEXBIN:=../nex} tacky.nex
${NEXBIN:=~/nex} tacky.nex
go tool yacc tacky.y
# Could use nex instead of ed, but that'd be a little gratuitous.
printf '/NEX_END_OF_LEXER_STRUCT/i\np *Tacky\n.\nw\nq\n' | ed -s tacky.nn.go
Expand Down
6 changes: 5 additions & 1 deletion tacky/tacky.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ func (tax *Tacky) Get(id string) int64 {
line.cached = true
line.n = tax.Eval(line.expr)
if tax.curForm.wholeDollarsOnly {
line.n = (line.n + 50) / 100 * 100
if (line.n >= 0) {
line.n = (line.n + 50) / 100 * 100
} else {
line.n = (line.n - 50) / 100 * 100
}
}
return line.n
}
Expand Down
1 change: 0 additions & 1 deletion tacky/tacky.y
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%{
package main
import "fmt"
%}

%union {
Expand Down

0 comments on commit 5afbc57

Please sign in to comment.