[HN Gopher] New Playground: Integer.exposed
___________________________________________________________________
New Playground: Integer.exposed
Author : duck
Score : 66 points
Date : 2023-05-05 07:07 UTC (1 days ago)
(HTM) web link (jvns.ca)
(TXT) w3m dump (jvns.ca)
| niedzielski wrote:
| I like little online tools like this! Suggestion: include some
| notes in the tool page itself on safe ints and references like
| https://blogs.mathworks.com/cleve/2017/05/08/half-precision-...
| TheMagicHorsey wrote:
| I had no idea that 1111..1111 was the smallest negative integer
| as opposed to 1000..0001.
|
| How did I not know that after nearly 25 years of programming? I
| must be dumb.
| detrites wrote:
| You just didn't happen to hit that particular thing in that
| time, there'll be a long list like that for all coders. The
| subset of coding and computer science anyone interacts with
| will always be small compared to the entirety of the field.
| [deleted]
| jwilk wrote:
| 1111...1111 is -1.
|
| 1000...0000 is the minimum.
| FreeFull wrote:
| Having 1000...0001 represent -1 would be sign-magnitude
| representation. Having 1111...1111 be -1 is two's complement.
| Computers usually use two's complement for integers, because it
| makes addition and multiplication really easy to implement.
| Floating point actually is closer to sign-magnitude, though.
| pwdisswordfishc wrote:
| You learn something new every day!
|
| The _lowest_ negative integer is still 1000...0000, though.
| duckqlz wrote:
| I'm confused by what you are saying?
|
| 111..11111 = -1 (for Nbit) 100..00000 = -2147483648 (for 32bit)
|
| Therefore 11...1 _is_ smaller than 100...01? Maybe I am dumb
| and missing something? Can anyone help?
| 2h wrote:
| if Julia is here, the HTML has an error:
|
| "style" element between "head" and "body"
| masklinn wrote:
| > The UI is a little different: integers don't have many
| different parts the way floating point numbers do
|
| Depends, they could if the site gave access to common varint
| formats for instance.
|
| Also can't help but think it's the wrong way around? I feel like
| when you play with byte order you want to see how the bits change
| for a given number, rather than the number for the same bits.
| Though I guess both are valuable, depends on your use case
| (whether you have a bit pattern and try to understand what it is,
| or have a number and try to see how it would encode).
|
| Exploring signed representations could also be useful.
| mshockwave wrote:
| > I feel like when you play with byte order you want to see how
| the bits change for a given number, rather than the number for
| the same bits.
|
| +1, as someone who is exclusive working on a big endian
| architecture this will be really helpful.
|
| related but slightly tangent: I hope there is a button for
| toggling 2's complement.
___________________________________________________________________
(page generated 2023-05-06 23:01 UTC)