Coder Social home page Coder Social logo

roundme's Introduction

roundme

roundme is a human-assisted rounding analyzer. It helps its operator determine whether an arithmetic operation should round up or down.

Features

  • Recommends whether an arithmetic operation needs to round up or down
  • Generates LaTeX-based reports in PDF

Rules

rounding() is the expected rounding direction for the result (up or down)

  • A + B => rounding(A), rounding(B) (addition does not change the rounding direction)
  • A - B => rounding(A), ! rounding(B) (the rounding direction of the substracted element is inverse of the expected rounding)
  • A * B => rounding(A), rounding(B), rounding(*) (multiplication does not change the rounding direction)
  • A / B => rounding(A), ! rounding(B), rounding(/) (the rounding direction of the denominator is the inverse of the expected rounding)
  • A ** B
    • If A>=1 => rounding(A), rounding(B)
    • If A<1 => rounding(A), ! rounding(B) (if A is below 1, the rounding direction of the exponent is the inverse of the expected rounding)

How to use

  • Run roundme init-sample to generate a default configuration file.
  • Run roundme init to generate user configuration file.
  • Run roundme analyze to analyze the configuration file
  • Run roundme analyze --output-format pdf to generate a PDF (require latexmk)

Running roundme analyze --output-format pdf on the default configuration will generate the following: Example

Configuration

roundme relies on a configuration file:

formula: a * b / c 
round_up: true
less_than_one: ["a * b"] # optional
greater_than_one: ["c"] # optional
  • formula contains the formula to be analyze
  • round_up determines if the result of the formula should round up or down
  • less_than_one is used for the ** rules (raw string comparison and sensible to space)
  • greater_than_one is used for the ** rules (raw string comparison and sensible to space)

See the balancer V2 example.

Install

Install with

cargo install roundme

To install the latest GitHub version

git clone [email protected]:crytic/roundme.git
cd roundme
cargo install --path .

roundme's People

Contributors

montyly avatar dguido avatar 0xicingdeath avatar smoelius avatar tarunbhm avatar

Stargazers

exd0tpy avatar Scooby avatar Paul Birnbaum  avatar Benjamin Samuels avatar Anak Mirasing avatar Parichaya Thanawuthikrai avatar Nishith Patnaik avatar  avatar rahul avatar cawfree avatar Magnetto avatar Daejun Park avatar Valentin B. avatar nikhil avatar 0x0918 avatar Async avatar blockreacher avatar Alexander Petrovich avatar Daniel Zarifpour avatar Egor Dergunov avatar  avatar clandestine.eth avatar Jonah1005 avatar Paco avatar natzuu avatar Bernd Artmüller avatar jess avatar Peter Goodman avatar  avatar Paulius avatar Shebin John avatar Samater avatar Shao avatar Hana Chang avatar Emiliano Bonassi avatar 蔡佳誠 Louis Tsai avatar tudouya avatar zetsukhun avatar Tadashi avatar Alberto avatar Febby avatar  avatar Camotelli avatar  avatar Pedro Bergamini avatar 0xfiending avatar  avatar Shawn Harmsen avatar Vlad Toie avatar Lev Menshchikov avatar Lawal Abubakar Babatunde avatar Bakuchi avatar Jack McPherson avatar  avatar blackbigswan avatar Rafael Nicolau avatar Luigi avatar Shun Kakinoki avatar Bogdan Cordier avatar M4tsuri avatar Georgios Konstantopoulos avatar Matt Solomon avatar Andrey Babushkin avatar Filip Kirin avatar Erwan Or avatar kvalerio avatar sudo rm -rf --no-preserve-root / avatar Nazgul avatar Milan Cermak avatar Atefeh Zareh avatar  avatar Christoph Michel avatar flaskr avatar Tristan avatar hobbescodes avatar Antonio Viggiano avatar Lubomir Anastasov avatar  avatar Pierrick Turelier avatar  avatar Dariusz Glowinski avatar Michael Amadi avatar Ben avatar pyk avatar wp-lai avatar

Watchers

Tadashi avatar  avatar

roundme's Issues

Feature: generate template code

Idea from @tjade273: we can generate template solidity code based on the formula. We can also auto generate a well formed documentation alongside

This will be useful in particular during the early stage development cycle.

We might need to templatize the generation to use the most common lib (ex: prb-math / solmate)

Question: rounding direction for multiplication

So on the generated reports, rounding directions are included for both multiplication and division operations. Why is a rounding direction included for multiplication, since there is no precision loss resulting from multiplication operations?

Thanks for making this tool!

Feature request: generate config file from static code analysis output

Hello
Great tool, thanks for building this!

I wish the config file was automatically generated from the source code.

This could be integrated into Slither, for example, which could extract all mathematical expressions, and the user would point out whether the different parameters (with names and links pointing to references in the code) were supposed to round up or down.

Feature request: support negative values

-1 * x will throw the following error

thread 'main' panicked at src/main.rs:61:60:
called `Result::unwrap()` on an `Err` value: UnrecognizedToken { token: (1, Token(7, "-"), 2), expected: ["\"(\"", "r#\"[0-9]+\"#", "r#\"[a-zA-Z]+\"#"] }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.