Hi!

I'm trying to display floating point numbers (money, that is) with two decimals with no luck. All trailing decimal zeros get cut off. Is there any way to work around this? Other number formatting functions such as round() or ceil() work with no probs.

Sample:

$sum = $node->field_t1_pieces[0]['value'] * $node->field_t1_price[0]['value'];
$node_field[0]['value'] = number_format($sum,2);

Cheers,
Mikko

Comments

deekayen’s picture

Category: bug » support
Status: Active » Closed (fixed)

I suspect that's the fault of having the incorrect field type. Make sure you defined the field as a decimal, not an integer.

Closing anyway because 5.x isn't supported anymore. You'll have to reproduce it in 6.x to re-open this.