# Why Max and Position do not work with NumberForm?

dats = Flatten@
ParallelTable[
NumberForm[RandomReal[], {3, 5}], {i, -4, 5, 1}, {j, 73}];



Then finding the max. value does not work

Max@dats


Similarly, if I want to find the position of an element

In[345]:= dats[[1]]

0.00089


The Position is not working too

In[346]:= Position[dats, 0.33900]

Out[346]= {}

• Look at the TreeForm for a NumberForm object; and try: Max[dats[[All, 1]]]
– Syed
Commented Feb 27, 2022 at 15:02
• For searching: Position[dats[[All, 1]], 0.05001168909146414] in my case gives: {{20}}. I had to manually copy and paste to get full precision.
– Syed
Commented Feb 27, 2022 at 15:08
• @Syed, but that destroys number form like to keep.. I need the output of data in 0.00000 and when searching use this form only. Commented Feb 27, 2022 at 15:12
• I tried SetAccuracy and it works now with Max but not for Position Commented Feb 27, 2022 at 15:17
• The idea (as I understand it so far) is to let Mathematica handle the numbers internally and format these at the end for display/reporting purposes. May I ask why you would like to use such functionality? Searching for an exact real number is not very useful and results in non-portable code. Usually inequality operators are used.
– Syed
Commented Feb 27, 2022 at 15:18

Remember, NumberForm is a wrapper. E.g.,

SeedRandom[314];
dats = Flatten@Table[NumberForm[RandomReal[], {3, 5}], {i, -4, 5, 1}, {j, 73}];
dats[[1]] // FullForm  (* NumberForm[0.9589271300722904,List[3,5]] *)


So if you want the biggests, you can try MaximalBy[dats, First].

On the other hand, if you round, then things work more how you seem to want.

SeedRandom[314];
dats2 = Flatten@Table[Round[RandomReal[], 0.00001], {i, -4, 5, 1}, {j, 73}];
dats2[[1]] // FullForm  (* 0.9589300000000001 *)
Position[dats2, 0.95893]   (* {{1}} *)
Max[dats2]  (* 0.99967 *)
Position[dats2, 0.99967]  (* {{209}} *)
`