Tag Info

23

UpArrow[a_, n_Integer] := Nest[a^# &, 1, n] then UpArrow[4, 3] or 4 \[UpArrow] 3 To complete this method you may wish to add an input alias: AppendTo[CurrentValue[$FrontEndSession, InputAliases], "up" -> "\[UpArrow]"]; Now EscupEsc will enter \[UpArrow]. Change$FrontEndSession to $FrontEnd and run it only once to make the change persist ... 22 SetPrecision[] does this: SetPrecision[0.1, ∞] 3602879701896397/36028797018963968 20 Introduction This seems to be a question more about IEEE 754 binary64 format than about Mathematica per se. The significand is 53 bits (52 stored, since the leading bit is assumed to be 1 in a normal number). When the input "0.1" is converted to a number, presumably, at some point 1. is divided by 10. The OP used the term "truncate," but more precisely, ... 20 Indeed, there is no direct method to input a repeating decimal. The closest you can get is to input the repeating digits into FromDigits[]: $$0.\overline{142857}$$ FromDigits[{{{1, 4, 2, 8, 5, 7}}, 0}] 1/7 $$0.\overline{3}$$ FromDigits[{{{3}}, 0}] 1/3 $$0.1\overline{6}$$ FromDigits[{{1, {6}}, 0}] 1/6 Of course, this also applies for e.g. ... 14 FromDigits@Flatten[IntegerDigits /@ Range] 123456789101112131415 A function to do it: numberFromRange[n_] := FromDigits@Flatten[IntegerDigits /@ Range@n] 13 In some settings the integers, fractions, rational numbers, reals, and complexes are five distinct systems. Further, for reals and complexes, there are the standard reals and complexes as well as nonstandard systems. There are mappings from some to others, so that a subset of the reals in an isomorphic image of the integers (as rings), and so on for${\bf Z}...

12

As noted in post, responses and comments, Real is a Mathematica head and, as such, is distinct from Integer and Rational and Complex. All of these are regarded as "atomic" (notwitstanding that Rational has two Integer "parts", and Complex is comprised of any mix of the other three types). These atomic types are in a sense distinct from the domains one ...

12

Mathematica will perform exact arithmetic only so long as all quantities are expressed as exact numbers. 90.12 is an inexact number with machine precision (i.e. floating point). Corresponding exact representations include 9012/1000 or 9012*^-2. For numbers with a finite decimal representation, we can use RealDigits to see all the digits along with a count ...

11

Here's a more general variant a(↑...↑)b with any given number of up-arrows, as defined on MathWorld: (* Short-hand for single arrow. *) UpArrow[a_, b_] := UpArrow[a, b]; (* Trivial case of a(↑...↑)1. *) UpArrow[_][a_, 1] := a; (* Single arrow: exponentation. *) UpArrow[a_, b_] := a^b; (* Generic case: do a recursion. *) UpArrow[n_Integer][a_, ...

11

Not as clean as J.M.'s method but this seems to give the same result: 0.1 ~RealDigits~ 2 ~FromDigits~ 2 3602879701896397/36028797018963968 Follow with Numerator and Denominator if needed.

11

Use the Resource Function ResourceFunction["RepeatingDecimalToRational"][0.3, 1] (* 1/3 *)

11

f1 = OrderedQ @* Rest @* IntegerDigits; f1 /@ {51369, 51396} {True, False} f2 = Apply[LessEqual @ ##2 &] @* IntegerDigits; f2 /@ {51369, 51396} {True, False}

10

There is a tolerance Internal$EqualTolerance that is applied when testing Real numbers. If the numbers agree up to the last Internal$EqualTolerance digits, then they are treated as equal. Try this: eps = 1.0; p = 0; Block[{Internal$EqualTolerance = 0.}, While[(1.0 + eps) > 1.0, eps = eps/2.0; p += 1]; ] eps p eps*2 (* 1.11022*10^-16 53 2.... 10 Already answered in the comments by DumpsterDoofus and Daniel Lichtblau, to summarize: Machine floating point numbers such as 0.2 are not always exactly representable in binary (no terminating expansion in base 2). Thus floating point arithmetic is susceptible to roundoff error and other accuracy problems. For example, the following are not exactly equal to ... 10 You can use SetPrecision to find a more precise result. r0 = 0.97646105481464028; r1 = Rationalize[r0] r2 = SetPrecision[r0, Infinity] 8795179285210031/9007199254740992 r2 - r0 0. If you increase the Precision of your input, you can get a rational number that is closer to 0.97646105481464028. Precision@r0 MachinePrecision r0 = 0.... 10 you can try this: integerQ[x_] := x == Round[x] 10 That can easily be done by separating each number into digits and re-assembling them as Number {3097, 3097, 3097, 3097} // IntegerDigits // Flatten // FromDigits 10 f1 = FromDigits @ StringRiffle[Range[#], ""] &; f1 /@ {4, 10, 15} {1234, 12345678910, 123456789101112131415} And f2 = FromDigits @* StringJoin @* IntegerString @* Range; f2 /@ {4, 10, 15} {1234, 12345678910, 123456789101112131415} A variation on @user1066's answer: f3 = Array[IntegerString, #, 1, FromDigits @* StringJoin] &; f3 /@ {5,... 9 PlusMinus[{x_, err_}] := Module[{errE = Last@MantissaExponent[err], xE = Last@MantissaExponent[x]}, Row[{"(", NumberForm[N@Round[x, 10^(errE - 1)]*10^(-xE + 1), {xE - errE + 1, xE - errE}], " \[PlusMinus] ", NumberForm[N@Round[err, 10^(errE - 1)]*10^(-xE + 1), {1, xE - errE}, ExponentFunction -> (Null &)], ")", " \[Times]... 9 However, the only method I've found that ensures numerically exact conversion is the manual one: delete the decimal point, and then divide by 10^z, where z is the number of digits to the right of the decimal. This does not produce an exact conversion because floating point numbers are represented in binary, not in decimal. I tried SetPrecision[a,Infinity]... 8 From FromDigits>>Details: For example: N@FromDigits[RealDigits[123.55555]] (* 123.556 *) 8 May be I'm overthinking this one. list = {0, 1, -2, 259}; f[x_, y_] := x + (2 Boole@NonNegative[x] - 1 ) y/10^IntegerLength[y]//N ; list /. {a_, b_, c_, d_} -> {f[a, b], f[c, d]} (* {0.1, -2.259} *) 8 As noted in the comments this behavior follows from the definition of FromDigits, though I only understood this myself within the last year or two when someone* used it to boost performance. Consider a symbolic example: sym = FromDigits[{a, b, c}] sym /. { a -> {a1, a2, a3, a4, a5}, b -> {b1, b2, b2, b4, b5}, c -> {c1, c2, c3, c4, ... 8 The documentation is misleading in this case. The wrapper NumberForm is not transparent to numerical calculation -- it stops it dead. This means you should only apply it to your final calculations when all the numerical work is done. So the following works. NumberForm[{n1, n2 - n1}, 3] {0.235, 0.766} If what you want is for all the numerical work in a ... 8 Original answer The reason for getting extra quotes is that these extra quotes are explicitly present in the box form of the expression generated by such functions as EngineeringForm, NumberForm etc.: ToBoxes@EngineeringForm[6.08717*10^6] TagBox[InterpretationBox[ RowBox[{"\"6.08717\"", "\[Times]", SuperscriptBox["10&... 8 The number entry form base^^digits is only valid for explicit [0-9] digits in the place of both base and digits. You cannot write literal b^^1001 and then attempt to replace b as b^^1001 does not parse to this input form. Likewise the number entry form m*^exp is only valid for explicit [0-9] digits in the place of both m and exp. The combination of these ... 8 Update This seems to do what you want a bit more simply than your own solution. f[{a_, b_}] := NumberForm[ SetAccuracy[a ± b, Accuracy @ SetPrecision[b, 2]], ExponentFunction -> (Null &) ] // ToString // Quiet Your test: f[{12.3456, 0.0123}] f[{12.3456, 0.123}] f[{129.3456, 1.23}] f[{-129.3456, 12.3}] f[{12.9999, 0.02}] f[{1, 100}] f[{-... 8 Rational is for exact numeric values, not symbolic expressions, i.e. its arguments must be integers. Rational[x,y] is syntactically valid input but no more meaningful than foo[x,y]. FindInstance[foo[x, y] =!= x/y, {x, y}, Integers] {{x -> 33, y -> 16}} FindInstance["meaningless" =!= x/y, {x, y}, Integers] gives the same output. Why values 33 and ... 8 This is at best a partial answer. I don't know in full detail what is going on with FullForm or InputForm but I will venture to guess they are influenced in some way by the$XXXPrecision settings. $MaxPrecision = 5;$MinPrecision = 5; InputForm[x = SetPrecision[10^(-10), 5]] (* Out//InputForm= 1.5.*^-10 *) InputForm[y = 1 + x] (* Out//InputForm= 1.`...

8

Try this IntegerString[62343, 16] // ToUpperCase

Only top voted, non community-wiki answers of a minimum length are eligible