GithubHelp home page GithubHelp logo

integer_division's People

Contributors

stevenhoving avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cpcitor xaphier

integer_division's Issues

Have programs generate the header files

Just a two-cent suggestion.

When writing issue #2, I expected the provided programs not only to do the computations and check for rounding errors, but also to generate the header files.

Create examples

This repo currently only holds the generates headers and the sources to generate them. It might be useful for other peeps to throw in some examples on how to use the headers.

Optimize the forgotten easy case of division by power-of-two

https://github.com/stevenhoving/integer_division/blob/master/integer_division_uint8.h show results that are technically correct for powers-of-two, although they can be obviously much simpler.

As we all know here, dividing by 2^n is just right shift by n bits. Current implementation shifts left by 7, then right by 8, then right by n-1.

Some compilers for regular platforms will most certainly simplify and generate code for the one simple shift.

Simpler compilers, especially for embedded machines which needs this kind of hack more than others, may not generate optimal assembly.

One might say "these are compile-time macros, if the divisor is a power of two, just do the usual shift".

Still, this is especially interesting for usage where the source code calling those macros is not written by a human but generated by some preprocessing step.

Also this work can be a basis for a division by a variable not known at compile time, via a table lookup of parameters. This case needs power-of-two to be handled also.

Merge 8-bit and 16-bit source codes.

Both programs are very similar. Only variable width and magic constants change.

The suggestion is to make a common source to be preprocessed to generate the two variants.

Pros:

  • would allow to have only one file to maintain. This is interesting when implementing #2 and #3.

Cons:

  • source code may be somewhat less readable when uint16_t becomes e.g. reg_int_t and most_significant_18_bits becomes most_significant_k_bits ?
  • emacs diff mode makes it easy to propagate changes between versions, which in practice erodes the benefit of the change (if the maintainer is comfortable with that).

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.