2

How can I get only those cases where the second column has only two decimal places or less?

ano=Range[2013,2100,1];
y=ano-1978; 
x=ano-2012;
anoRazao=Transpose[{ano,y/x}]//N

The figure below shows the results I want to get:

Figure

LCarvalho
  • 9,233
  • 4
  • 40
  • 96

2 Answers2

1

You can use string patterns like this:

allowed[{_, number_}] := StringMatchQ[
  ToString[number],
  ___ ~~ "." ~~ Repeated[DigitCharacter, {0, 2}]
  ]

Select[anoRazao, allowed] // TableForm

Mathematica graphics

C. E.
  • 70,533
  • 6
  • 140
  • 264
1

Using Mr. Wizard's modification of Stan Wagon's IntegerChop[] function, this can be done:

IntegerChop = # + Chop[#2 - #] &[Round@#, #] &;

Select[anoRazao,
       IntegerQ[IntegerChop[Apply[#1 10^(#2 + 2) &, MantissaExponent[Last[#]]]]] &]
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574