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:
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:
You can use string patterns like this:
allowed[{_, number_}] := StringMatchQ[
ToString[number],
___ ~~ "." ~~ Repeated[DigitCharacter, {0, 2}]
]
Select[anoRazao, allowed] // TableForm

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[#]]]]] &]
| DigitCharacter ...at the end of the pattern for that. – C. E. Aug 03 '16 at 21:56Caseto resolve the issue. – LCarvalho Aug 04 '16 at 02:01