Skip to content

Commit

Permalink
Resolve issue #10
Browse files Browse the repository at this point in the history
doc: update documentation for issue #8 and issue #9
  • Loading branch information
muktihari committed Oct 2, 2020
1 parent 01a6445 commit 35df377
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Expr is a string expression parser in go. Not a fancy eval, just a simple and li
- Float64 parses the given expr string into float64 as a result. e.g:
- "2 + 2" -> 4
- "2.2 + 2" -> 4.2
- "10 * -5 + (-5.5)" -> -55.5
- Supported operators:
- Arithmetic: [+, -, *, /]

Expand All @@ -56,12 +57,14 @@ Expr is a string expression parser in go. Not a fancy eval, just a simple and li
- Int parses the given expr string into int as a result. e.g:
- "2 + 2" -> 4
- "2.2 + 2" -> 4
- "10 + ((-5 * -10) / -10) - 2" -> 3
- Supported operators:
- Arithmetic: [+, -, *, /, %]
- Bitwise: [&, |, ^, &^, <<, >>] (signed integer)
- Notes:
- << and >> operators are not permitted to be used in signed integer for go version less than 1.13.x.
- Reference: [https://golang.org/doc/go1.13#language](https://golang.org/doc/go1.13#language)
- Even if bitwise is supported, the priority operation is not granted, any bit operation is advised to be put in parentheses.

```go
str := "((2 * 2) * (8 + 2) * 2) + 2.56789"
Expand Down
4 changes: 4 additions & 0 deletions expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
// - Supported operators:
// - Arithmetic: [+, -, *, /, %]
// - Bitwise: [&, |, ^, &^, <<, >>]
// - Notes:
// - << and >> operators are not permitted to be used in signed integer for go version less than 1.13.x.
// - Reference: golang.org/doc/go1.13#language
// - Even if bitwise is supported, the priority operation is not granted, any bit operation is advised to be put in parentheses.
func Int(str string) (int, error) {
expr, err := parser.ParseExpr(str)
if err != nil {
Expand Down

0 comments on commit 35df377

Please sign in to comment.