Can you describe it with doodle, it's hard to got the concept or what you want to achieve just by this statement.
say what now I'm not following since your quote is empty ?
but essentially in this post
http://forums.mozillazine.org/viewtopic ... &t=3096498
I'm trying to figure out how to replicate the functionality of
aka displaying a number to 3 significant digits the reason I'm trying to replicate the behaviour of .toPrecision instead of just using .toPrecision is twofold first .toPrecision rounds and so far as I'm aware there is no way to stop that since the .toPrecision method doesn't allow you to specify an optional parameter to control rounding which results in incorrect numbers being displayed for example 11.96054054054054 displays 12.0 when it should display 11.9
the second reason is because the project I'm working on is for a series of games specifically the X - Beyond the Frontier series therefore I'm trying to replicate the in game functionality as closely as possible and .toPrecision(3) is the JavaScript method that most closely replicates how coordinates display in game when you go to the map screen and highlight one of the objects in that sector
however currently as you can see in the this screen shot
https://i.ibb.co/brKTtXp/untitled.png I'm having issues because the coordinates are not being displayed to 3 significant digits as it is in game.
Unfortunately the truncateDecimals function that was posted here:
http://forums.mozillazine.org/viewtopic ... &t=3096498
is not giving the right output because its displaying numbers to 2 decimal places not 3 significant digits so again 11.96054054054054 displays incorrectly and the output I get is 11.96 not 11.9 which is how that particular coordinate would display in game.
now the obvious solution here is to tweak the truncateDecimals function unfortunately my knowledge of JavaScript is insufficient so I don't know how because currently my knowledge of JavaScript is only about high school level so there is a lot I still don't know so I tend to get stuck a fair bit particularly when I'm trying to do something like this that I haven't done before.
Now as for this post I was trying to figure out the simplest way to get the coordinates from the script to display in the coordinates table.
I had though that I could just insert the x_coordinate, y_coordinate and z_coordinate variables into the table but when I loaded the page the contents of the variables where not being displayed because obviously I'd done something wrong unfortunately again I'm not sure what the proper syntax is for inserting variables into the html and having there contents displayed upon loading the page.
so I ended up using different way of getting the contents of the variables to display which while it works is trickier and doesn't really scale well if you need to populate a much larger table which led to jscher2000 question about doing things server side but of course since this is only really intended for my use and will be run locally from my desktop doing things server side isn't really an option and beside that is way over complicated for what should in theory at least be a simple task aka
display a set of numbers to 3 significant digits without rounding and if there are less then 3 digits then pad with zeros for for example 12 becomes 12.0 which is what .toPrecision does if there aren't enough digits to match the specified level of precision
unfortunately this supposedly simple task is actually proving to be devilishly tricky since JavaScripts inbuilt methods for doing this sort of a thing don't allow you to control how or if they round which is incredibly irritating and more that a little bit frustrating for a JavaScript beginner such as my self.
so hopefully that makes things clearer and you can see how the 2 posts are linked because they are about 2 different aspects of the same task.