integer_division's People
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:
Cons:
- source code may be somewhat less readable when
uint16_t
becomes e.g.reg_int_t
andmost_significant_18_bits
becomesmost_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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.