English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

bash-2.05a$ echo 2147483646 | ascii2binary
1111 1111 1111 1111 1111 1111 1111 110
bash-2.05a$ echo 2147483647 | ascii2binary
1111 1111 1111 1111 1111 1111 1111 111

bash-2.05a$ echo 2147483648 | ascii2binary
1000 0000 0000 0000 0000 0000 0000 0000
bash-2.05a$ echo 18446744073709551614 | ascii2binary
1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0
bash-2.05a$ echo 18446744073709551615 | ascii2binary
1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0
bash-2.05a$ echo 18446744073709551616 | ascii2binary
1000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0

2006-09-03 10:06:28 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

There's clearly funny stuff going on here, but I don't see why we have to bring floating point into it. These are integers, and even the binary numbers given as output are clearly integers.

It's apparent that the ascii2binary program is using 64 bit integers to do its work, and that it is running out of bits. Programs like Mathematica don't have this problem, but perhaps it's asking too much for a straightforward utility to handle arbitrary magnitudes. Anyway, floating point is irrelevant here.

2006-09-10 18:27:29 · answer #1 · answered by arbeit 4 · 9 0

First 3 are alright; obviously, but last 3 is touching the thorny issue in floating point: lost of trailing precision because they are 65th bits but a float is not that big to hold precision. There you go.

2006-09-03 11:13:46 · answer #2 · answered by Andy T 7 · 0 1

fedest.com, questions and answers