5
$\begingroup$

The Mathematica parser parses and computes number literals before sending them to FullForm even if Hold is applied. Thus the full form of number literals is not accessible to the user.

The FullForm of an expression is just whatever FullForm spits out, and so in this sense the FullForm of a number input form is itself (or something close to itself). However, sometimes there is an alternative simple representation of an input form using nothing but head[] notation. For example, the input 1.234`55 is equivalent to SetPrecision[1.234, 55]. (This may or may not be what Mathematica is doing internally, but it is an equivalent representation.)

So can we construct an expression equivalent to 36^^sadjh.87s567*^-14 without using the ^^, `, ``, and *^ operators? The rules are that you can only use a decimal point, quotes, and built-in functions using head[] notation.

$\endgroup$
  • 3
    $\begingroup$ I would say the closest thing to a meaningful interpretation of this question is to say that the FullForm is BoxData["36^^sadjh.87s567*^-14"]. $\endgroup$ – Jens Apr 10 '15 at 23:46
  • $\begingroup$ The answer might be, "There just isn't a Head+Parts representation." But BoxData["36^^sadjh.87s567*^-14"] is definitely not the answer, as it's just how the notebook front end records the input form. You don't get BoxData[] on a command line, or through WSTP, or.... $\endgroup$ – Robert Jacobson Apr 11 '15 at 0:56
  • 2
    $\begingroup$ I agree that the most direct answer would be "it doesn't exist" - but I assumed that you wanted something more useful. Maybe it would help if you explained some more what your goal is. $\endgroup$ – Jens Apr 11 '15 at 1:12
  • $\begingroup$ Good suggestion. This is my first stackexchange post, so bear with me while I figure out how to edit the question. $\endgroup$ – Robert Jacobson Apr 11 '15 at 1:16
  • 1
    $\begingroup$ Perhaps you want ToExpression[BoxData["36^^sadjh.87s567*^-14"]] or MakeExpression[BoxData["36^^sadjh.87s567*^-14"], StandardForm], which is basically what happens when you hit shift-return (cf. Jens' first comment). $\endgroup$ – Michael E2 Apr 11 '15 at 3:13
7
$\begingroup$

The Mathematica parser parses and computes number literals before sending them to FullForm even if Hold is applied. Thus the full form of number literals is not accessible to the user.

You are making assumptions that are incorrect.

When Mathematica reads either 4 or 2^^100, it parses both to the exact same in-memory representation. After the parsing step, there's no additional evaluation step.

The "full form" of an expression is really just a human-readable canonical representation of in-memory expressions. FullForm gives 4 for both since they're exactly the same.

There are usually many ways to write the same expression. Another example is f@x and f[x] which are again represented identically in memory. In fact a good use of FullForm is to be able to tell if two expressions are identical.


2.`20 and SetPrecision[2., 20] are not identical. It is not correct to say that SetPrecision[2., 20] is the full form of 2.`20.

2.`20 parses directly to an atomic expression (a number).

SetPrecision[2., 20] is a compound expression which then evaluates to 2.`20. Now there is an evaluation step taking place after the expression is read in.

I hope this clarifies what's going on.

| improve this answer | |
$\endgroup$
  • $\begingroup$ To put it another way, the FullForm of 36^^sadjh.87s567*^-14 is exactly what you get by evaluating 36^^sadjh.87s567*^-14 // FullForm: 7.737144491656395`*^-15 $\endgroup$ – 2012rcampion Apr 11 '15 at 2:43
  • $\begingroup$ Converting 36^^sadjh.87s567 to 7.737144491656395`*^-15 is a computation done by the kernel whether or not an intermediate internal representation of the expression (normally accessible via FullForm) exists. $\endgroup$ – Robert Jacobson Apr 11 '15 at 17:18
  • $\begingroup$ @RobertJacobson That conversion is not an evaluation. There is no evaluation step happening. The conversion happens during the time when this string is read in and interpreted as a Mathematica expression. Is there any part of the answer you need me to clarify? $\endgroup$ – Szabolcs Apr 11 '15 at 17:41
4
$\begingroup$

I presume you asking for the number's internal form. Consider the following:

Precision[36^^sadjh.87s567*^-14]
MachinePrecision

So the number is internally a computer floating-point number. If you would like see all its digits, then

 NumberForm[36^^sadjh.87s567*^-14, 16]
7.737144491656396*10^(-15)
| improve this answer | |
$\endgroup$
0
$\begingroup$

Here's a partial answer that works if the number does not contain a decimal point:

SetPrecision[Times[FromDigits["sadjh", 36],Power[36, -14]], 55] == 36^^sadjh`55*^-14
True

One can easily imagine an alternate universe in which the left hand side of the above is the FullForm of the right hand side.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Before parsing, a FullForm does not exist. After parsing, the original textual representation is lost. So, yes, you can parse in whatever way you want if that makes your life easier, but as a model of what Mathematica does it is not correct. Incidentally, 1.234`55 and SetPrecision[1.234, 55] (in addition to not being the same, as mentioned by @Szabolcs) also do not produce the same result. In the former case, the padding is decimal zeros. In the latter, binary. $\endgroup$ – Oleksandr R. Apr 11 '15 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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