some simple and useful updates

- changed variable types to absolute lengths (stdint)
- added round() function for code readability
- improved the formatting of code blocks
- added comments to all the functions
- added basic range checking for bad values
- updated the example to provide some output