limit decimal numbers

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

limit decimal numbers

AlessioDL
Hi list,

I created a function returning the current map extent and updating values every time the user pan or zoom the map.

The function works fine and the effect is what I was looking for, but now I need to control how many decimal numbers appear after the comma separator.
For example I want to display always 5 decimal numbers after the comma...
There's a way to do such thing?

Thanks, alessio
Reply | Threaded
Open this post in threaded view
|

Re: limit decimal numbers

Jon Blower
Hi Alessio,

JavaScript 1.5+ has a toFixed() method to format numbers to a certain
number of decimal places and a corresponding toPrecision() method to
format using a certain number of significant figures.

http://www.pageresource.com/jscript/j_a_03.htm

Cheers, Jon


---------- Forwarded message ----------
From: Alessio Di Lorenzo <[hidden email]>
To: [hidden email]
Date: Mon, 15 Sep 2008 02:10:19 -0700 (PDT)
Subject: [OpenLayers-Users] limit decimal numbers

Hi list,

I created a function returning the current map extent and updating values
every time the user pan or zoom the map.

The function works fine and the effect is what I was looking for, but now I
need to control how many decimal numbers appear after the comma separator.
For example I want to display always 5 decimal numbers after the comma...
There's a way to do such thing?

Thanks, alessio

--
Dr Jon Blower
Technical Director, Reading e-Science Centre
Environmental Systems Science Centre
University of Reading
Harry Pitt Building, 3 Earley Gate
Reading RG6 6AL. UK
Tel: +44 (0)118 378 5213
Fax: +44 (0)118 378 6413
[hidden email]
http://www.nerc-essc.ac.uk/People/Staff/Blower_J.htm
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: limit decimal numbers

AlessioDL
Jon, thank you very much!
That's exactly what I need!

:)

Jon Blower wrote
Hi Alessio,

JavaScript 1.5+ has a toFixed() method to format numbers to a certain
number of decimal places and a corresponding toPrecision() method to
format using a certain number of significant figures.

http://www.pageresource.com/jscript/j_a_03.htm

Cheers, Jon


---------- Forwarded message ----------
From: Alessio Di Lorenzo <alessio.dilorenzo@gmail.com>
To: users@openlayers.org
Date: Mon, 15 Sep 2008 02:10:19 -0700 (PDT)
Subject: [OpenLayers-Users] limit decimal numbers

Hi list,

I created a function returning the current map extent and updating values
every time the user pan or zoom the map.

The function works fine and the effect is what I was looking for, but now I
need to control how many decimal numbers appear after the comma separator.
For example I want to display always 5 decimal numbers after the comma...
There's a way to do such thing?

Thanks, alessio

--
Dr Jon Blower
Technical Director, Reading e-Science Centre
Environmental Systems Science Centre
University of Reading
Harry Pitt Building, 3 Earley Gate
Reading RG6 6AL. UK
Tel: +44 (0)118 378 5213
Fax: +44 (0)118 378 6413
j.d.blower@reading.ac.uk
http://www.nerc-essc.ac.uk/People/Staff/Blower_J.htm
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users