![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
github.com/bocajim/evaler
https://github.com/bocajim/evaler
Project forked from https://github.com/soniah/evaler
Package evaler implements a simple floating point arithmetic expression evaluator.
Evaler uses Dijkstra's Shunting Yard algorithm [1] to convert an infix
expression to postfix/RPN format [2], then evaluates the RPN expression. The
implementation is adapted from a Java implementation at [3]. The results are
returned as a math/big *big.Rat
.
This is release 2.0. The previous version that returned results as float64 is in the branch float64.
result, err := evaler.Eval("1+2")
The operators supported are:
+ - * / ** () < >
< (less than) and > (greater than) will get lowest precedence, all other precedence is as expected (BODMAS [4]).
< and > tests will evaluate to 0.0 for false and 1.0 for true, allowing expressions like:
3 * (1 < 2) # returns 3.0
3 * (1 > 2) # returns 0.0
Minus implements both binary and unary operations (thanks @hiroxy).
The math/big library doesn't have an exponent function (**), and implenting one for big.Rat numbers is non-trivial. As a work around, arguments are converted to float64's, the calculation is done using the math.Pow() function, the result is converted to a big.Rat and placed back on the stack.
http://godoc.org/github.com/bocajim/evaler
There are also a number of utility functions (eg BigratToFloat(), BigratToInt()) that may be useful when working with evaler.
Sonia Hamilton http://blog.snowfrog.net sonia@snowfrog.net
Modified BSD License (BSD-3)
[1] http://en.wikipedia.org/wiki/Shunting-yard_algorithm
[2] http://en.wikipedia.org/wiki/Reverse_Polish_notation
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.