Jump to content

Wikipedia:Reference desk/Archives/Mathematics/2009 November 19

From Wikipedia, the free encyclopedia
Mathematics desk
< November 18 << Oct | November | Dec >> November 20 >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


November 19

[edit]

What do academic mathematicians contribute to society, and how effeciently?

[edit]

What do academic mathematicians (math researchers) contribute to society, if anything? And how efficient are they monetarily, or in terms of the money society pays for them compared in total with whatever they contribute. Thanks. 92.230.67.45 (talk) 07:09, 19 November 2009 (UTC)[reply]

I don't know exactly what they contribute but I believe they mostly develop tools that engineers and economists can use in the real world. I remember reading about a US politician saying: "Why do you physicists require such expensive toys? (He means particles accelerators). Now the math department just needs paper and a waste bucket, and the philosophy department is even better, they don't even need a waste bucket!". So think how much it's really costing the society even if you believe they are all useless Money is tight (talk) 07:34, 19 November 2009 (UTC)[reply]

I quote from Herstein's Topics in Algebra:

A popular myth is that mathematicians revel in the inapplicability of their discipline and are disappointed when one of their results is "soiled" by use in the outside world. This is sheer nonsense! It is true that a mathematician does not depend for his value judgements on the applicability of a given result outside of mathematics proper but relies, rather, on some intrinsic, and at times intangible, mathematical criteria. However, it is equally true that the converse is false—the utility of a result has never lowered its mathematical value. A perfect case in point is the subject of linear algebra; it is real mathematics, interesting and exciting on its own, yet it is probably that part of mathematics which finds the widest application—in physics, chemistry, economics, in fact in almost every science and pseudo-science.[1]

  1. ^ Herstein 1964, Chapter 6, p. 216

--PST 08:06, 19 November 2009 (UTC)[reply]

Well, for one, "academic mathematicians" provide most of the training for scientists of all fields. But what's more, they provide new mathematical results. Going by the past, some of these will be invaluable at some point - note that e.g. number theory, the useless "queen of mathematics", suddenly provided massive economic value with the invention of public key cryptography in the 70s. --Stephan Schulz (talk) 08:41, 19 November 2009 (UTC)[reply]
I disagree. Number theory is not (and was never) useless. It was always useful for those who enjoyed abstract thinking, and within mathematics itself. The important point to note here is that "use" has no precise meaning. Despite not being applicable in everyday life, number theory had tremendous use in training the minds of various mathematicians in the past. --PST 10:42, 19 November 2009 (UTC)[reply]
Not to mention number theory's roll in winning The War and internet commerce. These are hardly idle curiosities. —Ben FrantzDale (talk) 15:46, 19 November 2009 (UTC)[reply]

Mathematical results are not protected and not paid for. I the heirs of Pythagoras got a dime every time his theorem was used, they would be rich. Bo Jacoby (talk) 10:36, 19 November 2009 (UTC).[reply]

Don't give the MIAA any ideas!!! 92.230.68.113 (talk) 13:04, 19 November 2009 (UTC)[reply]


And let's quote the incipit of a famous paper by V. I. Arnol'd :

All mathematics is divided into three parts: cryptography (paid for by CIA, KGB and the like), hydrodynamics (supported by manufacturers of atomic submarines) and celestial mechanics (financed by military and by other institutions dealing with missiles, such as NASA.).

Cryptography has generated number theory, algebraic geometry over finite fields, algebra (the creator of modern algebra, Viete, was the cryptographer of King Henry IV of France), combinatorics and computers.

Hydrodynamics procreated complex analysis, partial derivative equations, Lie groups and algebra theory, cohomology theory and scientific computing.

Celestial mechanics is the origin of dynamical systems, linear algebra, topology, variational calculus and symplectic geometry. (Polymathematics : is mathematics a single science or a set of arts?, papers on-line by V.I.Arnol'd, 1999)

--pma (talk) 18:30, 19 November 2009 (UTC)[reply]
I had a professor who had a very simple answer to this question -- "Of what use is a baby?"--RDBury (talk) 22:47, 19 November 2009 (UTC)[reply]

Imaginary Numbers

[edit]

Why do we have them? If they don't really exist why are they so important?Accdude92 (talk to me!) (sign) 14:27, 19 November 2009 (UTC)[reply]

If they don't exist then of course they cannot be anything, let alone important. But the premise is wrong, they are very, er, real (pardon the pun).
If you have ever gotten AC electricity out of a wall socket to run anything, you can attest to their existence. Don't let the name fool you, it is merely a historical artifact. Baccyak4H (Yak!) 14:44, 19 November 2009 (UTC)[reply]
I am still confused. Historical artifact?Accdude92 (talk to me!) (sign) 14:53, 19 November 2009 (UTC)[reply]
They would probably have been given a different name today, but old names tend to stick even if they turn out to be inappropriate. See also Imaginary number which explains the name and uses. PrimeHunter (talk) 15:01, 19 November 2009 (UTC)[reply]
They are no more unreal than negative numbers. Lots of people have had problems even with them over the ages. They've even had problems with zero and irrational numbers (now there's a name to go with imaginary) Dmcq (talk) 15:13, 19 November 2009 (UTC)[reply]
"Irrational" is a good name, it means not a ratio. It is the use or "rational" to mean "logical" that is a strange use of language. --Tango (talk) 20:02, 19 November 2009 (UTC)[reply]
Not that strange. See what Vicipaedia has to say: la:ratio. The interesting question is how ratio came to mean the result of a division; I don't know the answer to that. Over the millennia language evolves in unpredictable ways. --Trovatore (talk) 22:53, 19 November 2009 (UTC)[reply]
What is the point of linking me to a Latin webpage? I don't speak Latin... --Tango (talk) 00:00, 20 November 2009 (UTC)[reply]
I thought all Brits had to study Latin. When did that change? --Trovatore (talk) 00:03, 20 November 2009 (UTC)[reply]
I don't think that was ever the case. The first standardized curriculum across (most of) the UK was in 1988, by which time Latin was no longer widely studied. When Latin was a reasonably standard part of the curriculum, this was only the case at private schools and grammar schools, never the schools for the less intelligent poor. Algebraist 17:41, 20 November 2009 (UTC)[reply]
In response to Trovatore's comment, the usage of ratio as proportion is apparently earlier attested than the philosophical/psychological definition. Notice I'm not speaking of the precise usage in the sense of "division". Pallida  Mors 01:02, 20 November 2009 (UTC)[reply]
That's strange -- according to Wiktionary, wikt:ratio#Latin, the word comes from the participle of reor, "I think". It gives "calculation" as an alternative meaning to "reason", which sort of makes sense, and then you can see how it might go from there to "division". But I have trouble working out how the word would travel the reverse path. I suppose it's possible that the two senses have separate etymologies. --Trovatore (talk) 01:09, 20 November 2009 (UTC)[reply]
Yes... The ethymology of a single word sometimes appears as a result of geological forces, that raise a mountain here and not there. The path of successive particularizations think → compute → divide is quite reasonable after all to get ratio. But what really scares me is the corresponding Greek term for ratio, λόγος, possibly the single word with the greatest impact on the human thought. --pma (talk) 04:16, 21 November 2009 (UTC)[reply]
As mentioned above, the name is an unfortunate historical accident. At the time, they seemed imaginary. Now I would say they are the group of 2D rotations and scaling. From an elementary standpoint, calling these "numbers" isn't necessarily natural. The fact that they are called "imaginary" is more or less related to the fact that it was surprising that the real numbers aren't closed under square root -- that the square root of a negative number isn't a real number but is something more or less like rotation(!). —Ben FrantzDale (talk) 15:22, 19 November 2009 (UTC)[reply]
This is a bit hand-wavey, but it helped me understand a little when I first came across them. If we can have a debt, i.e. negative numbers, then consider a debt consisting of area. The width and length of this negative area must be imaginary numbers. Readro (talk) 16:39, 19 November 2009 (UTC)[reply]
That's a bit too handwavy for me. A negative area can simply negative on one side and positive on the other side. Imaginary numbers never come up (I think) without real numbers around, so you are really looking at complex numbers. That is, i is the complex number with zero real part. And complex numbers are really just a notational convenience for things that can also be described with matrices. —Ben FrantzDale (talk) 19:47, 19 November 2009 (UTC)[reply]
Purely imaginary numbers are isomorphic to real numbers (as an additive group - they aren't closed under multiplication), so they are only really useful when considered as a subset of complex numbers. --Tango (talk) 20:02, 19 November 2009 (UTC)[reply]
Mathematical object have use (outside of the context of doing more math) because they can represent real world problems and phenomena. For example I can use the natural numbers to represent how many apples I have in my warehouse, or the real numbers to calculate my profits. Complex numbers (which include the imaginary numbers) turn out be really useful in a lot of different contexts, like quantum mechanics or electrical engineering or computer graphics or lots of other stuff that I don't really know about because I'm not an engineer, not to mention many deeper math applications. So that's why they're important. Whether mathematical objects exist depends on who you ask and what you mean by "exist". Real numbers don't have any higher existential status than imaginary numbers do. Rckrone (talk) 21:12, 19 November 2009 (UTC)[reply]
The idea that mathematics is solely for "the real world" and that people should only be required to know of this aspect of mathematics, is absurd (thus, "So that's why they're important", is incorrect). I understand that you are arguing that mathematics is important in everyday life, but the "mathematics" to which you refer is not really mathematics in my view. For instance, I would not call counting (as in counting the number of apples, or counting profits) in the most basic sense, mathematics. Mathematics that applies to the sciences does have a small chance of being called mathematics (or a large chance, depending on the science in question). However, the same cannot be said for "everyday life, common people mathematics". --PST 10:47, 20 November 2009 (UTC)[reply]
That's not what I was saying at all. Personally I don't give a crap about mathematics in everyday life. The apple example was only supposed to give a simple demonstration of the give and take between mathematics and real world problems. Keeping records of an inventory is one of the earliest math related problems in human history, and the natural numbers are one of the most fundamental mathematics objects there is. That's not a coincidence. I also don't particularly care about math applications, but the interplay with the real world is undeniably important to shaping where math is today. Whether it's inventory and natural numbers or topology and string theory, the point had nothing to do with accessibility to the man on the street. Rckrone (talk) 19:10, 20 November 2009 (UTC)[reply]
Of course it's really unlikely that you need the real numbers to calculate your profits — the rational numbers should do just fine.
To me the most interesting aspect of the term imaginary number is how it led, by back-formation, to real number, which is not a very perspicuous term. Names that would better express the concept would perhaps be line number or geometric number or continuous number, something like that. Students are introduced to the reals so gradually that I doubt they really appreciate the enormous conceptual leap from the naturals and rationals, which are sort of inherently algebraic, to the reals, which are inherently geometric/topological. --Trovatore (talk) 23:58, 19 November 2009 (UTC)[reply]
I completely agree. One day, in some course, I'd like to introduce the real line defining and characterizing it in a convenient way as an ordered set, without any algebraic structure (I guess, a totally ordered set with no max, no min, countable cofinality, dense in itself, and order complete). After, one should introduce additional structures on it: a topology, and the algebraic structure starting with a Z-action. After all, that is what often happens when fixing a scale in a class of magnitudes; the way one fixes the scale may be rather arbitrary in the lack of a natural set of translations. The main difficulty sems to be time, as usual. --pma (talk) 10:56, 21 November 2009 (UTC)[reply]
I would say the reals are inherently analytic (although one could argue that that is synonymous with topological). --Tango (talk) 00:03, 20 November 2009 (UTC)[reply]
Not one of the number systems we use are any more real. I consider the quaternions just as real as the natural numbers. There's nothing in nature that assigns the property "one" or "two" to an object. It is purely the human mind that creates the distinction between objects. Is a tree one tree, or 14,000 branches? Or 1,500,000,000 cells? Or a billion atoms? Where does nature put the label "one church" on a collection of bricks? All constructions. Everything is a lie —Preceding unsigned comment added by 81.149.255.225 (talk) 13:35, 20 November 2009 (UTC)[reply]

Well, of course they're used incessantly in electrical engineering.

And wherever Fourier transforms are used, which is just about everything. Michael Hardy (talk) 15:03, 20 November 2009 (UTC)[reply]

Conversion between Binary and Decimal.

[edit]

I know that if I take a nice, exact, decimal number like 0.2 and convert it to binary, I can get an annoying repeating binary number: .001100110011... So, with a finite number of bits, I can't always exactly represent a decimal number even though it has a finite number of decimal digits.

Is the reverse also true? Are there exact/finite binary numbers with no exact/finite decimal representation? I think the answer is "No" - but I can't prove it. That's certainly not true for base 3, for example. 0.1 in base 3 is 0.3333333... in decimal.

Assuming I'm right: What is the maximum number of decimal digits I'd need to represent any N bit binary fraction exactly?

TIA. SteveBaker (talk) 21:03, 19 November 2009 (UTC)[reply]

2 is a factor of 10, so any terminating binary decimal will be a terminating decimal decimal (if you'll excuse my terrible use of language). A decimal (assuming it is rational - if it isn't, you've got no chance) will terminate if its denominator is (or can be) a power of the base you are using. If the denominator is a power of 2 you can just multiply the numerator and denominator by the same power of 5 and you'll have a denominator which is a power of 10. --Tango (talk) 21:09, 19 November 2009 (UTC)[reply]
I'm going to try and answer your 2nd question as well, but I'm not sure this is going to work (I'm typing as I think because I can't be bothered to find pen and paper or open MS Notepad!). Let's assume the number is between 0 and 1 exclusive so we can just think about the fractional part. If it has N bits then it can be written as for some integer a. Then we can use my method above to get . That means it can definitely be written using N digits. It will be possible to write it using fewer digits only if is a multiple of 10. That would require a to be a multiple of 2, which would mean we had trailing zeros on the binary expression, which we should assume we didn't. Therefore an N bit binary expression can always be written as an N digit decimal expression and can never be written with a shorter expression unless the binary expression could have been. Well, that seemed to work... I wasn't expecting that answer though! --Tango (talk) 21:24, 19 November 2009 (UTC)[reply]
I should clarify - I was expecting N to be the maximum, but for some reason I didn't expect it to be the minimum too. --Tango (talk) 21:25, 19 November 2009 (UTC)[reply]
ec On the first question: the numbers that have a finite binary representation are those of the form n/2k, so called dyadic rationals. They also have a finite decimal representation -you can write them as 5kn/10k. I save this immediately to avoid edit conflicts, it's gonna be very hot in a few moments! ;-) --pma (talk) 21:13, 19 November 2009 (UTC)[reply]
(To expand upon pma's answer after ec) A finite length binary "fraction" = , where 0 or 1. This can always be written as where , which means that . This shows that a conversion from binary fraction to a decimal fraction can never expand the number of digits. Abecedare (talk) 21:22, 19 November 2009 (UTC)[reply]
Also since never ends with a zero in its decimal representation (always ends with a 5 in fact, although that part is irrelevant), you can confirm that a decimal fraction can also never have any fewer digits than a decimal fraction. Abecedare (talk) 21:29, 19 November 2009 (UTC)[reply]

We obviously have "great minds" at this board. ;-) Abecedare (talk) 21:31, 19 November 2009 (UTC)[reply]

( bet it's another ec) As to the second question, I think it's the same if we speak about integer numbers. With N binary digits we can make all numbers less that , that has digits in the decimal representation. --pma (talk) 21:34, 19 November 2009 (UTC)[reply]
Not, it doesn't. log(2) isn't an integer. It has the floor of that, I think (or maybe the ceiling, I'd have to think about it). --Tango (talk) 22:59, 19 November 2009 (UTC)[reply]
What, log(2) is not an integer? Really, you mean that 10 is not a power of 2? wow. --pma (talk) 06:56, 20 November 2009 (UTC)[reply]
2N has floor(N log10(2)+1) digits. Since log10(2) is irrational, this equals ceiling(N log10(2)), but this wouldn't work if 2 was replaced by 10 or 100, say. Algebraist 23:05, 19 November 2009 (UTC)[reply]
The answer to Steve's question doesn't depend on the relative magnitudes of the two bases, but rather on their shared/unshared prime factors (see below). Abecedare (talk) 23:22, 19 November 2009 (UTC)[reply]

Here is a general rule: Let b1 and b2 be two bases and let a number (<1) have a length N expansion in b1. Then:

  1. The number's expansion in b2 is guaranteed to be no longer than N iff is an integer.
  2. Further, The number's expansion in b2 is guaranteed to be exactly of length N iff b2 does not divide ; or if you want the result to be true for all N, b1 and m should have at least one unshared prime factor.

Counterexamples welcome! (I'll be offline for ~2 hours though). Abecedare (talk) 21:58, 19 November 2009 (UTC) Refined and extended. Abecedare (talk) 23:17, 19 November 2009 (UTC) [reply]

Wow! Many thanks as always. That's a rather unexpected (and personally quite annoying) result!

For those who care - I'm trying to convert a binary file containing Double precision floating-point format numbers into a human-readable ASCII (decimal) representation and back again...but without losing any precision in the process...not one single bit...guaranteed. The prospect of needing to print something like 53 digits in the worst case decimal expansion is...alarming!

What's weird is that I can store an N bit binary integer in somewhere between N/3 and N/4 decimal digits - but a binary fraction takes N digits - even though there is the same amount of "information" present in both cases. Now that I think about it - that's obvious because so many combinations of decimal digits (like 0.2) don't have exact binary representations - so there are a whole lot of N digit decimal numbers that don't have N digit binary representations - resulting in a lot of wastage in the decimal version.

But now that I think about it - I'm wondering whether I've even seen the worst possible case. I was thinking about binary fractions with N bits after the binary point...but with Double precision floating-point format, numbers are represented as mantissa x 2exponent...where the mantissa is in the range 1 to 2 and has 53 bits. The exponent could be as small as 2-2047 - so a true decimal expansion would need something like 2047+53 digits - so I have to represent the decimal version in mantissa/exponent form too - but I have to use 10exponent, not 2exponent - which presumably messes up the number of digits I need in the mantissa. Suddenly, an aparrently trivial programming task starts to get ugly!

So I think I may have to resort to plan B - which is to print the binary representation out in hexadecimal - with an approximate decimal expansion next to it for human-readability. Damn!

Anyway - thanks again! SteveBaker (talk) 04:52, 20 November 2009 (UTC)[reply]

Let's have a go at the mantissa/exponent version. Once again, I'm typing as I think, so I have no idea where this is going! We have a number a*2^b that we want to turn into c*10^d=c*2^d*5^d, so clearly a=c*5^d*2^(d-b). If a has N bits then we know that , so . Now, we know and we want to know so we have:
Giving a number of digits of:
That is, obviously, a big mess, but if you give me a minute I'll try and tidy it up! --Tango (talk) 07:32, 20 November 2009 (UTC)[reply]
Ok, plugging a few numbers (rounded to 2dp where appropriate):
Ergo, large numbers can be written with a negative number of digits. I think that might be wrong... I found a sign error. --Tango (talk) 08:04, 20 November 2009 (UTC)[reply]
That still can't be right, can it? It's far too small... Can anyone see the mistake? --Tango (talk) 08:16, 20 November 2009 (UTC)[reply]
I see at least a couple of problems:
  • I think you missed that
  • You have "a has N bits then we know that ". That's not true since the equation implies that
Here is my rough analysis of why an exact conversion from IEEE64 representation to decimal may result in a number with large numbers of digits: As Steve described an IEEE64 number is of the form where , and has 53 significant bits; and (roughly). Lets consider the boundary cases, which you'll see represent the worst-case scenarios:
  • Consider the number . This is approximately a 300 digit number in decimal representation, with nonzero LSB; so it's exact decimal representation with require storing around ~300 digits. If we consider the more general case of that adds on another ~50 odd digits since a itself has potentially 50 digit representation in decimal (recall our analysis above). There is some further overhead for storing the exponent but that's just 3 digits long. Adding up, such numbers require upto ~350 digits to store.
  • Consider the number . Note that the factor just has the effect of moving the decimal point in the decimal representation, and we need to look at the part to count the number of significant digits. Now is approximately a 750 digit long number, again with non zero LSB. Following the first example above, numbers like can therefore require about 800 digits for exact decimal representation.
In short, IEEE64 numbers can require upto 350 digits or 800 digits for exact decimal representation (depending upon whether the binary exponent is positive or negative), and there is no real way to get around this. One can potentially come up with clever computation (or compression) schemes so that the representation is computed on the fly, but the final answer, if it is to be displayed will necessarily be much longer than the 64 bits, at least in the worst case. Sorry Steve, that's life the math. Abecedare (talk) 09:12, 20 November 2009 (UTC)[reply]
So the problem with mine is that it is all nonsense - thanks! The problem with yours is that you've forgotten the mantissas are of bounded length. In your first example the original number is only accurate up to +/-2^967, so we only need to quote the decimal up to +/-5*10^290, so we can truncate the last 290 digits of your 350 digit number. --Tango (talk) 09:36, 20 November 2009 (UTC)[reply]
Oh, I certainly agree that it doesn't make much sense to store upto 800 digits for a quantity that is only defined in terms of 53 bits. However, if we wish the binary and decimal representations to correspond to the exact same number (as Steve, I think, wants to), we do need all those excess digits. The analysis above was just stating that as a mathematical truism; as a practical scheme truncation would be the way to go, as you suggest. Abecedare (talk) 09:49, 20 November 2009 (UTC)[reply]
Steve wanted to get the exact same number back when he converted back to binary, which you would with the truncated version. --Tango (talk) 09:52, 20 November 2009 (UTC)[reply]
True. Hope he reads to the end of this thread, and doesn't give up halfway.  :-) Abecedare (talk) 10:02, 20 November 2009 (UTC)[reply]
No, no, no! I'll read every word! Having put everyone to the trouble of answering a RefDesk question, it would be exceedingly rude not to pay rapt attention to all of the responses. SteveBaker (talk) 14:50, 20 November 2009 (UTC)[reply]
Steve, glibc contains a function that will convert an IEEE single- or double-precision float into the shortest string that will read back as that same number (using, e.g., scanf). It originally comes from another source and I think it is not [L]GPLed but possibly public domain. That's all I remember; I hope it helps. -- BenRG (talk) 10:45, 20 November 2009 (UTC)[reply]
Well, I remember a bit more. Java's Float.toString and Double.toString produce output that's guaranteed to read as the same float/double, so tracking down an open-source implementation of those might be the way to go. GNU Classpath implements them using the function I mentioned previously. -- BenRG (talk) 10:56, 20 November 2009 (UTC)[reply]
The article Rounding has a bit about 'The table-maker's dilemma' which is the problem of getting the closest approximation of mathematical functions. I'll have a look myself too for that glibc function as it sounds like the rounding article should refer to it. A quick calculation tells me you'd have to put out a bit more than twice the number of significant digits to have a good chance of always converting back to the exact same number. Dmcq (talk) 14:00, 20 November 2009 (UTC)[reply]
It looks to me like Java is able to restrict it to 17 digits at most by sometimes converting to a number that is exactly half way between two doubles. The input routine converts such a number to the double that has a 0 in the least significant bit. So it has a bit of agreement between the input and output. Without that agreement you'll have trouble. Dmcq (talk) 14:44, 20 November 2009 (UTC)[reply]
There's no way to avoid the need for matching input and output routines if you need exact round-tripping. The C standard doesn't even guarantee that for every float/double there exists a string that will produce it if scanf'd. I think (but don't take my word for it) that gcc and MSVC's scanf will round properly according to the current rounding mode, which will be round-to-even unless you change it. If you can't rely on a particular C library then you need your own input routine. This is just as hard to write as the output routine; you can't just add together the digits multiplied by their place values because it won't be properly rounded. So don't try. Steal a floating-point wizard's source code instead. -- BenRG (talk) 17:59, 20 November 2009 (UTC)[reply]
Thanks! That's all useful info. I'll try to track down that glibc function. This is one of those situations where I'm trying to solve a very big and complicated problem and it's being tripped up by one annoying little detail - representing double precision floats in human-readable ASCII. The rest of the larger problem is essentially solved, leaving what seems at first sight to be the most trivial part as the major stumbling block! I agree that I could truncate that 53 decimal digit representation down to considerably fewer digits and still have it convert back to binary as the same value that I started with - but absolutely guaranteeing that gets a bit tricky.
@Dmcq: The entire problem here is that having "a good chance" of converting back to the exact same number isn't good enough in this case. I need not only to always get the binary value back perfectly - but I have to be able to convince doubting team members that whatever I do has that property. SteveBaker (talk) 14:50, 20 November 2009 (UTC)[reply]
Well it looks like you always can do that with I think probably 15 or perhaps 16 digits I haven't found the routine yet. The problem is he halfway case. You can bump the last digit up or down one to be certain it converts back to the exact same hexadecimal form however the input deals with halfway cases. However the Java method means the decimal figures are a correctly rounded form whereas to get around the input routine other than in java you might want to output a number that wasn't correctly rounded. Anyway that's my reading of it. Dmcq (talk) 14:57, 20 November 2009 (UTC)[reply]
The only thing I see in glibc is the '%a' format for printf/scanf. However, it prints/scans a hexadecimal floating point number(!):
"The ‘%a’ and ‘%A’ conversions are meant for representing floating-point numbers exactly in textual form so that they can be exchanged as texts between different programs and/or machines. The numbers are represented is the form [-]0xh.hhhp[+|-]dd. At the left of the decimal-point character exactly one digit is print. This character is only 0 if the number is denormalized. Otherwise the value is unspecified; it is implementation dependent how many bits are used. The number of hexadecimal digits on the right side of the decimal-point character is equal to the precision. If the precision is zero it is determined to be large enough to provide an exact representation of the number (or it is large enough to distinguish two adjacent values if the FLT_RADIX is not a power of 2, see Floating Point Parameters). For the ‘%a’ conversion lower-case characters are used to represent the hexadecimal number and the prefix and exponent sign are printed as 0x and p respectively. Otherwise upper-case characters are used and 0X and P are used for the representation of prefix and exponent string. The exponent to the base of two is printed as a decimal number using at least one digit but at most as many digits as necessary to represent the value exactly."
...which doesn't really meet the "human readable" requirement (at least, not for all values of "human").
SteveBaker (talk) 15:42, 20 November 2009 (UTC)[reply]
Silly me. I should think about it better to start with. If you print out a double to enough decimal places so it is sepearated from the ones beside it then the value on conversion back will always be exact. There isn't anything to worry about. That'll happen for something like 15 or 16 digits I'm not sure which. One doesn't need to do any twiddling of last digits or anything like that. Dmcq (talk) 16:04, 20 November 2009 (UTC)[reply]
You need 17 digits for double precision. Then every decimal representation of a double will differ from the next by at least 2 in the least significant digit, DBL_EPSILON is about 2.2e-16. Every such number can then be accurately converted back to binary. Dmcq (talk) 16:31, 20 November 2009 (UTC)[reply]
Yep 17 digits. Here's a draft of the IEEE spec [1] and under '5.12.2 External decimal character sequences representing finite numbers' that's what it says. So much easier and less error prone when I find someone else saying it. Dmcq (talk) 16:49, 20 November 2009 (UTC)[reply]
I've added a section to the floating point article about it: IEEE 754-2008#Character representation Dmcq (talk) 17:10, 20 November 2009 (UTC)[reply]