Everpure Interview Question

which number can be represented as two decimal?

Interview Answers

Anonymous

Oct 8, 2018

bool fitsInTwoDecimal(float a) { return ((a*100) - (int)(a*100)) == 0; }

Anonymous

Apr 27, 2015

In base-2 only rationals with denominators that are powers of 2 (such as 1/2 or 3/16) are terminating. Any rational with a denominator that has a prime factor other than 2 will have an infinite binary expansion. (Source wiki)

1