Seems random. I've got it working though, changed real to float. I seem to get different results with my little test program though.

Here's from my full program. (I think there's a function in phobos to do this any way):

char[] cashToString(dub money,char[] paddingForCents="".dup) {
  char[] amount;
  if ( money<1f ) {
    float cents=money*100f;
    amount=format("%s%d",paddingForCents,cast(int)cents);
  }
  else
    amount=format("%0.2f",money);
  return
    format("%s%s%s", money>=1f ? "$" : "", amount, money<1f ? "c" : "");
}

Reply via email to