Simon is an unfortunate user victim of a piece of middleware known as the Core Enterprise Foundation. Like many of its kind, the CEF is a .NET-based framework designed to make programmers' lives easier and, most importantly, allow them to write enterprise-class code. The primary way that the CEF accomplishes these goals is by simplifying the data types available to its users.

Programmers familiar with .NET or, really, any other platform, are familiar with "standard" data types: integer, single, double, date-time, string, boolean, and so on. Programmers familiar with the CEF need to know only two: Numbers and Strings. And because no one in the real world uses "decimal" numbers, the CEF further simplifies this by using only integer numbers.

Now before you go and say, wait a minute, money is real-world decimal number, let me remind you that the designers of the CEF have already thought about that. Although you may think of money as dollars and cents, in the real world, money is just cents, "beautified" (as the CEF architects say) with a "dollar unit" and a decimal place. The same can be said about every other possible example that you or anyone else can ever think of, ever.

To model this reality, the CEF adds a "Decimal Place" metadata attribute to each Number Field. Should a user of the CEF ever need to "beautify" a Number with a decimal place, all he needs to do is call the SetDecimalPlace() method. It takes all the pain out of querying the Entity Metadata Repository (also known as the EntityFieldMetaData table) and presents your "beautified" Number ...

public string SetDecimalPlace(int number, string field, string entity)
  //throw exception if bad input
  if (field.Length == 0 || entity.Length == 0) return "-1";

  //easy return
  if (number == 0) return "0";

  //find the places 
  int places = this._getDecimalPlaceForField(field, entity);

  //build zeros
  StringBuilder zeros = new StringBuilder(places + 1);
  for (int i = 0; i <= places; i++)

  //append to number
  string value = zeros.ToString() + number.ToString();

  //insert decimal
  value = value.Substring(0, value.Length - places) +
      + "." + value.Substring(value.Length - places, places);

  return value;