Skip to content

Commit

Permalink
Large modifiers (#32)
Browse files Browse the repository at this point in the history
* npf__int_t and npf__uint_t typedef'd for large or normal. add macros to extract and writeback through specified types

* fix up readme, make all float forms just do %f

* bigger coversion buffer, more conformance tests

* writeback large modifier tests

* ignore .ii

* negative float conformance

* initialize val to calm gcc
  • Loading branch information
charlesnicholson authored Jul 7, 2019
1 parent ab34e86 commit c649f85
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 95 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cmake-build*

# preprocessed / asm files
*.i
*.ii
*.s

# Object files
Expand Down
2 changes: 1 addition & 1 deletion .ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
flags = [
'-DNANOPRINTF_IMPLEMENTATION',
'-DNANOPRINTF_USE_FLOAT_FORMAT_SPECIFIERS=1',
'-DNANOPRINTF_USE_C99_FORMAT_SPECIFIERS=1',
'-DNANOPRINTF_USE_LARGE_FORMAT_SPECIFIERS=1',
'-DNANOPRINTF_USE_WRITEBACK_FORMAT_SPECIFIERS=1',
'-Wall',
'-Wextra',
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[![CircleCI](https://circleci.com/gh/charlesnicholson/nanoprintf.svg?style=shield)](https://circleci.com/gh/charlesnicholson/nanoprintf) [![](https://img.shields.io/badge/license-public_domain-brightgreen.svg)](https://github.com/charlesnicholson/nanoprintf/blob/master/LICENSE)

nanoprintf is an implementation of snprintf and vsnprintf for embedded systems that aims for C11 standard compliance.
nanoprintf is an implementation of snprintf and vsnprintf for embedded systems that aims for C11 standard compliance.

nanoprintf makes no memory allocations, uses less than 100 bytes of stack, and is around 5KB of ARM Cortex-M object code when optimized with all the bells and whistles turned on (slightly larger on x64).
nanoprintf makes no memory allocations, uses less than 100 bytes of stack, and is smaller than 5KB of ARM Cortex-M object code when optimized with all the bells and whistles turned on (slightly larger on x64).

nanoprintf is a [single header file](https://github.com/charlesnicholson/nanoprintf/blob/readme/nanoprintf.h) in the style of the [stb libraries](https://github.com/nothings/stb). The rest of the repository is tests and scaffolding and not required for use.

Expand Down Expand Up @@ -92,6 +92,18 @@ Like `printf`, `nanoprintf` expects a conversion specification string of the fol
* `%n`: Write the number of bytes written to the pointer vararg
* `%f`/`%F`: Floating-point values

## Limitations

No wide-character support exists: the `%lc` and `%ls` fields behave like `%c` and `%s`, respectively.

No decimal exponent notation support exists: `%e` and `%E` behave like `%f` and `%F`, respectively.

No "dynamic" decimal / exponent notation support exists: `%g` and `%G` behave like `%f` and `%F`, respectively.

No hexadecimal exponent notation support exists: `%a` and `%A` behave like `%f` and `%F`, respectively.

Pull requests welcome!

## Acknowledgments

Float-to-int conversion is done using [Wojciech Muła](mailto:zdjęcia@garnek.pl)'s [algorithm](http://0x80.pl/notesen/2015-12-29-float-to-string.html).
Loading

0 comments on commit c649f85

Please sign in to comment.