loading

Pointless C# Code Snippet Of The Week

I was bored.
I thought "I bet you could write some very slick code to turn a decimal into a fraction."
So I did.

private string FractionFinder(double target)
  {
  int divider = 1;
  int result;
  while (!int.TryParse((1 / target * divider).ToString(), out result))
    divider++;
  return string.Format("{0} / {1}",divider,result);
  }
(unrated) | by madkat on January 29th, 2008

An account is required to post comments

COMMENTS

I don't know what this "C#" is, or thinks it is, but I don't like the look of that. It's weird.

(unrated) | by defproc on January 29th, 2008
See the lie. | Powered by: Apache / PHP / MySQL | Made in Ninjapad NX | © defproc.co.uk, 2007_