If you're passing it as a numeric literal, e.g.:

     {  "price":  14.20  }

...what you're dealing with is a number, which you'll later *render*
as a string for display.  All JavaScript numbers have the same
precision, which I'm not quite geeky enough to quote you. ;-)  You'll
need to handle formatting at the presentation stage.  Since these are
prices, formatting is pretty straightforward, as the precision doesn't
vary from one price to the next.

If you needed to handle this for numbers where the precision varied,
you'd have to either pass them as strings or pass the precision as a
separate value for use in your formatting code.

T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Mar 4, 9:50 pm, Bob <bro...@packagingcorp.com> wrote:
> I'm relativley new to PrototypeJS. I
>  am doing some calculation in a back end program and returning a JSON
> string to my web page. One of the values is a price. If I return
> 14.20, it gets converted in evalJSON to 14.2. I want to keep both
> digits. I can find how to pad the left of a nmber to a certain number
> of places, but can't seem to find anythig about keeping decimals out
> to a set number of places.
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to