Using hex in jquery's setInterval() and setTimeout()
Asked Answered
T

1

5

I am making a script that checks to see if a server is connected or has gone away.While looking around how others have done it,i realized that some are using hex inside the function.For instance setInterval(l,6E4)

Another example

setTimeout(function(){d(window.checknet.config.checkURL)},window.checknet.config.checkInterval)}a=a||{};a.checkURL=a.checkURL||window.location.href;a.checkInterval=a.checkInterval||5E3;a.warnMsg=a.msg||"No Internet connection detected, disabled features will be re-enabled when a connection is detected. ";

This is the use of hex a.checkInterval=a.checkInterval||5E3;

Why is hex being used instead of ordinary decimal figures?.

Timisoara answered 22/1, 2014 at 8:39 Comment(0)
L
20

That is not hex, its a number written in Scientific Notation, 6 x 104.

= 60.000

As the time of setInterval is in milliseconds, if you want to use an integer as seconds, it's easy to use it like: Ne3 being N = seconds.

1e3 = 1000 = 1 second

Edit:

Hex numbers are written with the prefix 0x.

Levalloisian answered 22/1, 2014 at 8:42 Comment(2)
Where can i learn more about writing that way i mean NE4,what notation is this?.Timisoara
Nice! I found this one too: mathsisfun.com/index-notation-powers.html. This is a good way to represent huge numbers.Maples

© 2022 - 2024 — McMap. All rights reserved.