How do I shorten returned coordinates?

388 Views Asked by At

Using Cycript (mixed with javascript) via a tweak I have this code:

var latitude = [IS2Weather currentLatitude];

This returns -1.65456038607131e+25

I want to limit it to 6 decimal places (-1.654560), what is the correct way to achieve this please? I can't seem to get anything to work.

2

There are 2 best solutions below

2
Munawir On BEST ANSWER

Use javascript .toFixed(n) method

latitude = latitude.toFixed(6);
4
Evan Lucas On

Have you tried calling latitude.toPrecision(6)?