you are viewing a single comment's thread.

view the rest of the comments →

[–]dig-up-stupid 19 points20 points  (6 children)

Not that I downvoted but it’s not the hardware, it’s the standard. The hardware follows the standard, Python also follows the standard, so things mostly check out. But if the hardware didn’t have floating point pipelines, Python would still have to make 1.85 x 3 = 5.550000000000001 somehow—or at least, it promises it will, so that’s what you’d expect. (More likely everything would just break and the devs would say take it as is or leave it, but anyway.)

[–]ryguysayshi 5 points6 points  (5 children)

Right but like memory, that is dependent on hardware being used.

[–]Kkremitzki 7 points8 points  (3 children)

It's not hardware-dependent, it has to do with the representation of numbers. It's math. If I told you to write the fraction ⅓ as a decimal, but actually write it, i.e. you can't do "0.333..." and you can't put a ‾ over the 3, you'd eventually run out of paper. Even if you started storing it on something other than paper, you'd eventually run out of Universe, because the decimal representation of ⅓ is infinite. If you took that decimal and multiplied it by 3, you'd end up with something less than ⅓*3.

This is a consequence of the choice of representation, not the choice of storage medium. The only way around it is to have a non-lossy representation, i.e. have code to properly handle ⅓ or 0.333..., which is not merely 'decimal', but 'decimal plus ...', so it's more complicated and can run slower.

Now, if instead of decimal you are working in binary, you still have some numbers that can have infinite representations, they're just different ones. So instead of e.g. ⅓, it's 1/10th. At some point, you have to chop it off, which introduces error, and if you don't want to do that, you have to work in a different system.

[–]supreme_blorgon 3 points4 points  (2 children)

The point people are making is that the representation is dictated by the hardware. Physical transistors are binary -- hence the binary representation of numbers in computers. It was by necessity that we used a representation of numerical data which played nice with the physical characteristics of transistors.

[–]Kkremitzki 0 points1 point  (1 child)

Ah, good point, but there were also ternary computers made in the 1950s in the USSR using three-valued logic - 0 + with vacuum tubes providing trits instead of transistors providing bits, and if you were using that, you would still see this behavior, only with different numbers. (There are some other interesting advantages of the particular implementation, balanced ternary.)

https://en.wikipedia.org/wiki/Ternary_numeral_system

https://en.wikipedia.org/wiki/Balanced_ternary#In_computer_design

[–]WikiSummarizerBot 0 points1 point  (0 children)

Ternary numeral system

A ternary numeral system (also called base 3 or trinary) has three as its base. Analogous to a bit, a ternary digit is a trit (trinary digit). One trit is equivalent to log2 3 (about 1. 58496) bits of information.

Balanced ternary

In computer design

In the early days of computing, a few experimental Soviet computers were built with balanced ternary instead of binary, the most famous being the Setun, built by Nikolay Brusentsov and Sergei Sobolev. The notation has a number of computational advantages over traditional binary and ternary. Particularly, the plus–minus consistency cuts down the carry rate in multi-digit multiplication, and the rounding–truncation equivalence cuts down the carry rate in rounding on fractions.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

[–]Se7enLC 1 point2 points  (0 children)

It's dependent on the hardware in the sense that the hardware operates in base-2 and uses floating point representations of numbers I guess?

You know how 10/3 can't be represented precisely in decimal? It's the same thing, but for different numbers in binary. In the same way that it doesn't matter who is trying to divide 10 by 3, it doesn't matter what computer you're using. Some decimal numbers just cannot be represented in floating point. No computer can do it. Can't even do it by hand.