Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Javascript all the variables exist with values associated with them.

My question is if the division sign is incorrect for Javascript because I am getting no result.

JavaScript
var JD = Math.floor(365.25 * (yr + 4716)) + Math.floor(30.6001 * (mo + 1)) + dy + (2 - Math.floor(yr / 100) + Math.floor(Math.floor(yr / 100) / 4)) - 1524.5 + (hr24 + mn / 60 + (sc) / 3600 - (tz + dst)) / 24;


What I have tried:

I have tried using the "%" in place of:

JavaScript
var JD = Math.floor(365.25 * (yr + 4716)) + Math.floor(30.6001 * (mo + 1)) + dy + (2 - Math.floor(yr % 100) + Math.floor(Math.floor(yr % 100) % 4)) - 1524.5 + (hr24 + mn % 60 + (sc) % 3600 - (tz + dst)) % 24;


I have also used the "%" just in Math and if statements. Are these correct?
Posted
Updated 7-Jul-18 6:29am

It is clearly documented here: JavaScript Operators[^].
 
Share this answer
 
The division sign is correct, but your equation or values may not be.
Try breaking the calculation up into sections:
var temp1 = Math.floor(365.25 * (yr + 4716));
var temp2 = Math.floor(30.6001 * (mo + 1));
var temp3 = 2 - Math.floor(yr / 100);
var temp4 = Math.floor(Math.floor(yr / 100) / 4)
var temp5 = hr24 + mn / 60 + (sc) / 3600 - (tz + dst);
varJD = temp1 + temp2 + dy + temp3 + temp4 - 1524.5 + temp5 / 24;
Then either use a debugger to look at the values, or output them to your page so you can see exactly what is going on.

I have no idea what that calculation is supposed to give you, or a clue as to the values you are feeding it, so I can't fix it for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900