Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is a partial answer on Stack Overflow, but I'm asking something a teeny bit more specific than the answers there.

So... Does the formal semantics (Section 7.2) specify the meaning of such a numeric literal? Does it specify the meaning of numeric operations on the value resulting from interpreting the literal?

If yes, what are the meanings (in English -- denotational semantics is all greek characters to me :))?

share|improve this question
up vote 1 down vote accepted

Reading from the standard:

If the written representation of a number has no exactness prefix, the constant may be either inexact or exact. It is inexact if it contains a decimal point, an exponent, or a ``#'' character in the place of a digit, otherwise it is exact.

Basically remember they amount to insignificant figures. The compiler isn't required to have any specific value for them there but it must put something. (most use zero). It's a way of making a number imprecise.

share|improve this answer
Yes, that is what the standard says, which I noted indirectly in my question. It does not, however, define the meaning of 123#4. I was wondering if there was a specification of the meaning of # in place of a digit in the formal semantics. My assumption is that it was probably intended for symbolic manipulation of numbers (ie sig-figs and how they propagate) but it's not specified in the standard's English text. – ikmac Dec 10 '12 at 0:12
It's illegal to randomly substitute in # for digits, they have to group together at the end of the number. It is similar to writing 1.23 * 10^4 or 123# except a # isn't guaranteed to be 0. – jozefg Dec 10 '12 at 0:17
thanks for pointing that out -- I see it now in the grammar. Ok, so it seems to have been originally intended to represent lack of precision (ie a measurement with N significant figures), although implementations appear to simply replace #'s with 0's and mark the number inexact, then forget about the #'s, which seems to defeat the purpose. Also, I've just looked at R6RS, which has dropped this. – ikmac Dec 10 '12 at 19:12
yeah it's kinda silly in my experience. generally explicit 0's are better for representing insignificant digits, especially since they work correctly in math stuff – jozefg Dec 10 '12 at 19:14
Agreed. 0's work fine when using straight numbers etc. The #'s would require numbers be handled symbolically (treating each run of #'s as both 0's and 9's to determine how many digits in the result of an operation are indeterminate and should be replaced with #'s) -- so that's probably why the meaning wasn't specified, only the effect of making a number inexact. – ikmac Dec 10 '12 at 19:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.