groda_lotsapot Posted October 26, 2006 Share Posted October 26, 2006 The other day my boss asked me to write a quick little webpage that would quickley generate a password given someone's numeric login (for the sake of this board, I have modified the actuall equation) Problem was, although the equation was correct, I was getting incorrect results... turns out he was using VBScript, and I was using JavaScript.... and his answers were actually incorrect.Basically if you feed both VB and JavaScript the number 111408.77845966595 and tell them to convert to a string, you get 2 different results:JavaScript = 111408.77845966595VBScript = 111408.778459666What's with that?See the following examples of our code below. <script language="JavaScript" type="text/javascript">function NewPassJava(acdid){ var pass = acdid / 3.141592654; pass = String(pass); pass = pass.replace(".",""); pass = pass.substr(pass.length-4,4); pass = pass.replace("0","1"); return pass;}</SCRIPT> <script language="vbscript" type="text/vbscript">function NewPassVB(acdid) pass = acdid/3.141592654 pass = CStr(pass) pass = replace(pass,".","") pass = Right(pass,4) pass = Replace(pass,"0","1") NewPassVB = passend function</SCRIPT> Link to comment Share on other sites More sharing options...
groda_lotsapot Posted November 11, 2006 Author Share Posted November 11, 2006 Anyone figure this out yet? I now fear having to write any software that has anything to do with math cause of this (well... at least in VBScript). Also, woudn't this cause 'issues' in something like a payroll system? Link to comment Share on other sites More sharing options...
jesh Posted November 13, 2006 Share Posted November 13, 2006 Anyone figure this out yet? I now fear having to write any software that has anything to do with math cause of this (well... at least in VBScript). Also, woudn't this cause 'issues' in something like a payroll system?I think in 90% of cases, taking a number out to the nearest billionth is overkill. If you round to a more reasonable number - say 111408.77846 - then both scripting languages would/should match. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now