Code Monkey home page Code Monkey logo

reciprocal's Introduction

Baseline implementation of division by constants

Build Status Coverage Status

When dividing integers by compile-time constants, compilers (LLVM) can be trusted to convert those to a sequence of multiplication and shift.

That doesn't work so well when the constant isn't known until runtime.

This crate implements a simple strategy with reliable performance. Does reliable imply good? For this application, it does.

The basic PartialReciprocal should be compiled to a constant-time fast path, and can handle every divisor except 0, 1, and u64::MAX.

The slightly more complex Reciprocal can also divide by 1 and u64::MAX, at the expense of one more u64 field, and a slightly more complex (one more load, maybe one more integer arithmetic instruction) fast path.

reciprocal's People

Contributors

pkhuong avatar

Stargazers

Jevin Sweval avatar Tobin Baker avatar Darko Trifunovski avatar Jason Bowen avatar  avatar Jarek Przygódzki avatar David Brown avatar Jiacai Liu avatar Cycatz avatar ebigram avatar wren romano avatar Ruihang Xia avatar Elliott Mahler avatar Torben Clasen avatar Ruslan Prakapchuk avatar Enrico Lumetti avatar Chris Lin avatar HAOYUatHZ avatar Declan Kelly avatar Alex Kirszenberg avatar Georgios Konstantopoulos avatar  avatar Shawn Walker-Salas avatar

Watchers

Jevin Sweval avatar  avatar

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.