Questions tagged [number-representation]

Questions about interpretation of numeric input or how Mathematica stores and manipulates numbers internally.

Filter by
Sorted by
Tagged with
19
votes
5answers
2k views

Is this the most efficient way to round approximate integers to integers while leaving other Reals untouched?

This might seem like an overly simple question, but I need to specify custom plot tick marks as integers (no trailing decimal point) if they are approximately integers, but not if they are not. Using <...
66
votes
3answers
3k views

When can I assume that all decimal digits returned by Mathematica are provably correct?

How to Control the Precision and Accuracy of Numerical Results Arbitrary-Precision Numbers Mathematica works with exact numbers and with two different types of approximate numbers: machine-...
9
votes
3answers
1k views

Mod[1.2, 0.2] is not equal to zero

Why doesn't the following expression evaluate to zero? In[1]:=Mod[1.2, 0.2] Out[1]=0.2 Edit: This is what I wanted to do: ...
6
votes
1answer
305 views

Calculations after NumberForm [duplicate]

As specified in documentation center the functions AccountingForm, NumberForm, etc. are useful only to display numbers in ...
12
votes
3answers
1k views

Expression of uncertainty in measurement.

I have a problem with writing a Mathematica function. I have been requested to show the results of my experiments with the measurement uncertainty (mu) like below: ...
8
votes
2answers
937 views

Enter exact rational numbers easily with decimal notation

Is there a simple way to enter decimal numbers such as 0.123 so that Mathematica interprets it as an exact rational number 123/1000?
10
votes
1answer
334 views

Is it possible to lower the bitwidth of (floating point) numbers?

The answer to this question will most probably be a definite no. Nevertheless, I would like to know whether it is possible to represent reals in the memory on less than the standard 32 or 64 bits (...
2
votes
1answer
125 views

Unexpected behavior from `NumberForm` of a matix [duplicate]

If I calculate the dimension of the matrix after NumberForm directly, then there will be something wrong ...
11
votes
2answers
784 views

Does Mathematica have an equivalent of Python's float.as_integer_ratio?

The Python programming language has a float.as_integer_ratio(x) function which exactly converts an IEEE 754 floating-point number into a numerator/denominator pair ...
11
votes
2answers
686 views

Understanding simple numerical calculation

I am trying to understand why N[0.1]//FullForm returns 0.1' (A). Indeed, $0.1$ in base two is $0.000110011001100110011...$. If I ...
6
votes
5answers
2k views

How to get exact Rationalize of a decimal number?

This is on Mathematica 11.1 on Windows 7. I have this value 0.97646105481464028 which I'd like to get exact rational for it. I have thought that every terminating ...
5
votes
3answers
274 views

How can I improve NumberString?

I would like to test strings to see if they represent numbers. This should include number representations with precision marks and scientific notation. NumberString ...
3
votes
2answers
777 views

hexList[[1]] returns a list of decimal numbers

Sorry for not being clear about this question earlier. I appreciate the answers I got, but the edits I made should make the question more understandable. I have been working with hex in Mathematica,...
14
votes
1answer
2k views

Number format in Legend Labels

I would like to use the usual (new and nice) BarLegend[] with something like BarLegend[{"LakeColors", 1/10000 {-2, 2}}] which ...
10
votes
2answers
450 views

How to copy formatted numbers as MathML without quotation marks?

I have the following code: a = 6.08717*10^6; b = a/3; c = a*1.5; d = a^2; matrix={{a, b, c, d},{b, c, d, a},{c, d, a, b},{d, a, b, c}}; matrix // EngineeringForm ...
4
votes
1answer
158 views

NumberForm and Precision

With MachinePrecision this construction works as expected ...
9
votes
1answer
536 views

Machine Epsilon

I'm trying to evaluate the machine epsilon of my computer (see below). I wrote this: ...
6
votes
2answers
3k views

Converting numbers to integers

I've read the available documentation but I still haven't found an NumberForm -> Integer function yet. No result in this site's search, either. Does it exist? ...
2
votes
3answers
157 views

Testing for a vector of reals [closed]

Suppose I define: RealVector[expr_]:=VectorQ[expr,NumberQ[#]&&Head[#]===Real)]; Then: ...
0
votes
2answers
204 views

The precision of the number

I have problem in Mathematica with unnecessary rounding which is caused by high precision. For example I have value a = 2.052685846*10^-1865, when I make ...
24
votes
3answers
2k views

Real Numbers in the Wolfram Language

Epilog: Much of the discussion in the answers below revolves around the distinction between Real as a data type and real numbers as a domain or class of numbers (irrespective of the form in which ...
11
votes
1answer
4k views

How do I get Mathematica to show a number in non-exponential form? [duplicate]

Sometimes I make a calculation in Mathematica that produces a big number, which Mathematica shows like so: -1.52522*10^7 This is annoying to me, because I want ...
8
votes
1answer
204 views

Arbitrary-Precision Arithmetic behaves unexpectedly

I want to understand how small numerical errors propagate through a computation and may drastically change the final result. To this end, I consider a toy world in which every number is limited to ...
5
votes
3answers
852 views

Customizing decimal mark used in plot frame tick labels

I am using the Plot function in a usual way. I use Mathematica 9.0.1.0 in English (I do not know if it is available in other languages, but I do not mind), and as a ...
4
votes
1answer
176 views

LieArt — 3 different 8 dimensional irreducible representation of $\mathrm{SO}(8)$ and their decompositions

I am using the LieArt which you can download freely online https://arxiv.org/pdf/1206.6379.pdf There are three different 8 dimensional $\mathrm{SO}(8)$ irreducible representations, formally it is ...
9
votes
2answers
4k views

Convert a string to hex number?

How can I convert a string containing a hex number such as "6b" to a hex digit that mathematica can use to do math with? I have tried using ...
7
votes
1answer
171 views

Problem to import numbers longer than 19-digit with “JSON” or “RawJSON”

Bug introduced in 11.0.1 or earlier and fixed in 12.0. MMA 11.0.1.0 (Windows 10, 64-bit) I see that "JSON" import can be buggy (154245), so my question is simple: can the following behaviour be ...
4
votes
1answer
123 views

ExponentFunction not respected in NumberForm when typesetting zero?

Let's try to typeset a couple of numbers with a precision accuracy of 4: 0``4 1``4 1000000``4 I do not want the numbers returned with ...
3
votes
0answers
146 views

Rationalize error

The docs state that "Rationalize[x,dx] yields the rational number with smallest denominator that lies within dx of x." However, testing this out it appears to be false. ...
5
votes
2answers
246 views

Display All Output Numbers in HEX

How might I modify Mathematica such that I can get the following functionality when working with HEX values. The odd lines are input and the even output. Red values should be the HEX values. What ...
5
votes
2answers
169 views

Showing AlgebraicNumber[1/2 (1 + Sqrt[5]), {-3, 2}] in human-readable way

Is there a function to show algebraic numbers in Mathematica more conveniently? I am looking for something similar to MatrixForm for matrices. For example, I would like to view ...
5
votes
2answers
171 views

Early vs. late application of arbitrary precision

The following arbitrary-precision computations, in which arbitrary precision is applied early (to the inputs), both work as expected: ...
4
votes
2answers
101 views

StringTemplate does not respect NumberFormat

I am trying to write Latex report generator for my standard data analysis. But there is an issue with formatting numbers I can not get around. I would like to make use of my own ...
4
votes
2answers
408 views

What is the most efficient way to add zeros to end of a number?

Beside *10^n, is there a faster way to add thousands of zeros to end of a number? Updated Timings: ...
4
votes
1answer
184 views

How can I completely discard decimals after a set number of significant figures?

I have a number with a long decimal tail, like x=1.23456789789456123 and I would like to (i) keep the first $n$ significant figures, and (ii) completely discard ...
2
votes
1answer
294 views

Converting a quantity to a decimal form [closed]

I have a function giving me this: (5 Coulomb)/(6 Second) as output. I want this in decimal form and would like to have the variables taken off the end for unit ...
2
votes
1answer
157 views

How to plot data that are already in scientific form? [duplicate]

I've got an array of data shown in scientific form. Which looks like this: x = {0.0001,ScientificForm[0.999890436521418]} Now I'm trying to use ListPlot to plot ...
1
vote
1answer
740 views

What is the fastest way to split a number into parts?

I have very large numbers (million digits). number = A*10^partlen + B As of now, I split the numbers by this way: ...
1
vote
3answers
73 views

How to get string from the result of BaseForm function

I want to get the string "b0.3ae" In:=BaseForm[176.23, 16] Out:=Subscript[b0.3ae, 16] And then I want to get 176.23 by ...
0
votes
1answer
930 views

How can I change the default output number form to accounting form?

By default, large numbers are displayed in scientific form in output like 1.2345 x 10^8 in Mathematica 8.0.4, but I would prefer having numbers in accounting form ...
0
votes
0answers
93 views

Maintaining working precision in my program

I am badly stuck with this program I am writing. I want output of program below to be precise up to 25 digits after decimal point. I am supplying all inputs with precision 25. But after each iteration ...