Skip to content

Conversation

@fhunleth
Copy link
Contributor

@fhunleth fhunleth commented Jan 5, 2018

Before:

iex> inspect(-1, base: :hex)
"0x-1"

After:

iex> inspect(-1, base: :hex)
"-0x1"

This change also applies to the octal and binary base options.

Before:

iex> inspect(-1, base: :hex)
"0x-1"

After:

iex> inspect(-1, base: :hex)
"-0x1"

This change also applies to the octal and binary base options.
@NobbZ
Copy link
Contributor

NobbZ commented Jan 5, 2018

Negative non-decimals with an unary minus to display signedness feels odd in general.

If bitwidth is known use 2-complement or if not either use decimal output or fail.

This is just an opinion though...

@wojtekmach
Copy link
Member

Negative non-decimals with an unary minus to display signedness feels odd in general.

one way to look at it is that -0x1 is valid Elixir syntax and 0x-1 is not.

@josevalim josevalim merged commit df17e81 into elixir-lang:master Jan 5, 2018
@josevalim
Copy link
Member

❤️ 💚 💙 💛 💜

josevalim pushed a commit that referenced this pull request Jan 5, 2018
Before:

iex> inspect(-1, base: :hex)
"0x-1"

After:

iex> inspect(-1, base: :hex)
"-0x1"

This change also applies to the octal and binary base options.
@fhunleth
Copy link
Contributor Author

fhunleth commented Jan 5, 2018

All of you are quick with reviews! Thanks!

@fhunleth fhunleth deleted the inspect-negative-base branch December 7, 2020 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants