'double is no valid Common Lisp type specifier, I assume you meant 'double-float, and here is what happens:Paul wrote:The OP said scanf(3) can do it, so he's talking about ASCII decimal representations, not binary format. In which case, READ will read them (just set *read-default-float-format* to 'double).
Code: Select all
CL-USER> (setf *read-default-float-format* 'double-float)
DOUBLE-FLOAT
CL-USER> 100,0
error: comma is not inside a backquote
CL-USER> 1,000,000.0
error: comma is not inside a backquote
CL-USER> 1.000.000,0
error: The variable |1.000.000| is unbound.
DSP machines (producing measurement data) usually work with assembly code, not with C and there are still many mesurement machines using 8-bit and 16-bit architectures, and in a 8-bit architecture a "double" has 16-bit.Paul wrote:C requires that a "double" have at least 37 bits of mantissa equivalent, so there are no 16- or 32-bit "double"s.
What I meant was of course:Paul wrote:Can you give an example of an "inexact approximation of a number"?
Code: Select all
CL-USER> (float 1/3)
0.33333334f0
That's true - [David Goldberg: What Every Computer Scientist Should Know About Floating-Point Arithmetic]marcoxa wrote:Guys... we (should) all have read Goldberg's paper, but that has little import to the OP question...
But that unfortunately doesn't change the fact that the question can't be answered as long as nothing is known about the floating-point print format. C's scanf cannot serve as a reference because it can't read floating-point numbers correctly.
The main topic of my rant was (and still is):
I have to deal every day with floating-point measurement data in printed form, either in ASCII or Unicode data-files or printed on paper, where nothing is known about the tolerances involved from hardware limitations like unknown quantisation depth or software limitations introduced by sample frequency interpolation or floating-point rounding errors, so the data is virtually useless. This is even worsened by the fact that most english/american C-programs cannot even interpret printed floating-point data correctly.
C's scanf has only very limited functionality and in most cases can only read number printed by C's printf but not by other programming languages. Same to say about Lisp's READ, that only can read numbers in Lisp format. [Same to say about the scan or read functions of any other programming language].
So the original question still remains: Is there any solution known how to read floating-point numbers in any print-format correctly?
- edgar