number-format

In jQuery, what's the best way of formatting a number to 2 decimal places?

This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function? ...

format a number keeping its sign in php

Is there a way to format in PHP a number always keeping its sign (+ or -)? In .NET this will be something like: string myString = number.ToString("+#;#"); ...

getting an odd division error with PHP number_format()

my script calculates a number X by dividing two other numbers, A by B. X=A/B when i use number_format(A,2) on A before calculating X, i get a very odd number. Actual figures: 1,045.00 / 5 = 0.2 but if i don't use number_format on A before the division, i get the correct answer. Is number_format somehow making A into a non-number? ...