Skip to content

Print negative numbers as negative numbers regardless of base #4535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Print negative numbers as negative numbers regardless of base #4535

wants to merge 1 commit into from

Conversation

cousteaulecommandant
Copy link
Contributor

Base 10 is not special. Printing a negative number such as -15 in base 16 should show -F, not FFFFFFF1. For the result with the many Fs, the number should be converted to unsigned long (or unsigned int for fewer Fs).
Issue #4460 complains about the behavior of print for negative ints (which prints them as unsigned long), and I think the best solution would be to be consistent with what negative integers actually represent rather than with what printf does in C.

Make negative integers be represented with "-" in any base, not just base 10.
@facchinm facchinm added the Print and Stream class The Arduino core library's Print and Stream classes label Jan 20, 2017
@CLAassistant
Copy link

CLAassistant commented Apr 9, 2021

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Print and Stream class The Arduino core library's Print and Stream classes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants