The only thing a binary computer can store is a bit. A bit is either 0 or
1, both are integers. Or we can say that it can only store booleans true
and false, but that doesn't change anything important as the cardinality of
those sets are the same

Everything else is an agreed upon interpretation of one or more bits.


On Fri, Aug 15, 2025, 10:28 'Bushnell, Thomas' via golang-nuts <
golang-nuts@googlegroups.com> wrote:

> That’s a great page, but this part is a whopper: “Computers can only
> natively store integers.” If we mean “what the hardware directly does” it
> doesn’t “store integers”, it represents them by patterns of magnetic fields
> or whatever. But there is nothing “native” about the method used to store
> integers, certainly not compared to the way it stores fractions.
>
>
>
> There are just representations, none of them more native than another.
> There are whole languages in which rational numbers are stored exactly.
> (And since floating point stores rational approximations only, this isn’t a
> difference.) You can even design languages which store *real numbers *exactly.
> (Wait, what? Doesn’t it require infinite memory to store an arbitrary real?
> Of course it does! But you cannot *input *an arbitrary real, and so you
> only need to store what you can input [always finitely representable] and
> compute. And you can compute with, well, magic; stay tuned.)
>
>
>
> So it is a decent explanation of the basics and an overview of languages.
> But that’s a whopper.
>
>
>
> Ok, now as it notes, Scheme has a notion of “exactness”. How might we go
> about representing real numbers exactly in Scheme, once we note that we are
> only on the hook for representing what we can input and the results of
> computations? Well…. You store them symbolically!
>
>
>
> So your *pi *constant is just a symbol “pi” and you don’t try to
> represent its decimal expansion at all until you output it. (And when you 
> *output
> *it, you only need to print so many digits, which you can compute * as
> you output them.*) So what about double that? Or its square root? Same
> thing…represent it symbolically, and then do the necessary computation of a
> series expansion at the time you output the number. This is terribly
> inefficient, of course. I’m not suggesting it’s a replacement for floating
> point numbers (nor are exact rationals, though they should get more use
> than they unfortunately do). But it is not impossible, and, more to the
> point, it is not “less native” than integers.
>
>
>
> (Unless by “native” you mean “implemented by assembly instructions”, but
> then, floating point are implemented by assembly instructions…)
>
>
>
> Thomas
>
>
>
>
>
> *From:* 'Brian Candler' via golang-nuts <golang-nuts@googlegroups.com>
> *Sent:* Thursday, August 14, 2025 10:04 PM
> *To:* golang-nuts <golang-nuts@googlegroups.com>
> *Subject:* Re: [go-nuts] Rounding to k digits
>
>
>
> This message was sent by an external party.
>
>
>
> On Wednesday, 13 August 2025 at 20:10:50 UTC+7 Peter Weinberger (温博格)
> wrote:
>
> The canonical reference on this is by Guy Steele, "How to Print
> Floating Point Numbers Accurately"
>
>
>
> See also:
>
> https://0.30000000000000004.com/
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/golang-nuts/090d49ac-4b72-4978-9943-d4362e309fe0n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/090d49ac-4b72-4978-9943-d4362e309fe0n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/golang-nuts/aefacfc1b522482bb3b33d3dbc08b8fa%40deshaw.com
> <https://groups.google.com/d/msgid/golang-nuts/aefacfc1b522482bb3b33d3dbc08b8fa%40deshaw.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-Xf_yQEmd8tdRgP7QqN4B2eBSdEUFTFZ6Z7mbc1eXjFsg%40mail.gmail.com.

Reply via email to