|
Until you write stock trading software in Javascript and you end up buying an infinity of shares because somewhere along the line, some value in some database was 0 that you used in a denominator to figure out how many shares to buy.
Marc
|
|
|
|
|
That's just example code man, cut me some slack. It's Christmas!
Jeremy Falcon
|
|
|
|
|
You didn't know about NaN yet? Or infinity? Or that JS uses elephanting floats all over the place?
It gets better, 1/0 is positive infinity but 1/-0 is negative infinity, even though 0 and -0 compare equal to each other.
|
|
|
|
|
|
harold aptroot wrote: You didn't know about NaN yet? Or infinity? Or that JS uses elephanting floats all over the place? Everyone knows about NaN, what I didn't know was that I could safely divide by zero without crashing the JavaScript engine / interpreter.
Jeremy Falcon
|
|
|
|
|
That positive 0 and negative 0, of course has nothing to do with JS...
It comes from the IEEE 754 standard, and you can find it in C# implementation too...
Exception handling is very expensive in terms of computer resources, so we already used to validate user input...In this case JS follows to the letter the standard...
https://en.wikipedia.org/wiki/IEEE_floating_point[^]
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I wrote: Or that JS uses elephanting floats all over the place
|
|
|
|
|
Maybe you only need some parentheses like that:
aveMeSomehow.result = ( isNaN(result) || !isFinite(result) ) ? 0 : result;
to get things running.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
I'm glad my college math professor doesn't program in JavaScript, he'd have a fit seeing a variable equal to infinity.
Nothing is ever equal to infinity because it isn't a single number. The result of an equation tends to infinity when a certain condition becomes true (I suck at math so I don't think any explanation would make much sense)
In the divide by zero example, the limit of x/n as n tends to zero is infinity.
|
|
|
|
|
veni bibi saltavi
|
|
|
|
|
Thanks man! Cheers.
Jeremy Falcon
|
|
|
|
|
.NET does exactly the same thing with floating-point arithmetic. AFAIK, so does Java.
The behaviour is required by IEEE-754[^]:
The 754 model encourages robust programs. It is intended not only for numerical analysts but also for spreadsheet users, database systems, or even coffee pots. The propagation rules for NaNs and infinities allow inconsequential exceptions to vanish. Similarly, gradual underflow maintains error properties over a precision's range.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I never knew that. Thanks.
Jeremy Falcon
|
|
|
|
|
Here's the thing.
JavaScript's way of handling divide-by-zero is not better or worse than any other. It simply is.
If you have code that should do something specific when a divide-by-zero happens, then you damn well better code it that way. If you are depending on the the language for that specific behavior, then for Pete's sake emulate that behavior when you move to a language that doesn't have the behavior.
JavaScript does not matter. C++ does not matter. Algol does not matter. Only the behavior you want matters. So, know the language, and code accordingly.
|
|
|
|
|
The BASIC that came with the Heathkit computers was way ahead of the game.
It's error message said, "I'm a computer, not God" when you would divide by zero.
Psychosis at 10
Film at 11
Those who do not remember the past, are doomed to repeat it.
Those who do not remember the past, cannot build upon it.
|
|
|
|
|
Mathematically, these are the correct answers.
0/n = 0; Since 0 =/= Infinity, 0/0 is Not a Number (NaN)
Lim(1/n)(as n=>0) => infinity; specifically aleph(null). There are multiple infinities and this is just the first of them.
So, regardless of what you think about JavaScript, it handles division by zero properly.
|
|
|
|
|
|
I don't know about auto-ticketing (innocent until proven guilty, after all), but a "black box" arrangement recording the last hour of driving, which is saved to write-once memory when the car detects a crash sounds like a good idea.
The 1-hour overwrite limit would limit "fishing" for old speeding incidents etc. by the police. Storing the data after an accident in write-once memory would help prevent tampering with the evidence. If the system erroneously recorded an accident, the evidence in the write-once memory would help exonerate the driver.
Sounds like a win-win to me.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
https://en.wikipedia.org/wiki/Lytx[^]
The taxi cabs at the company I used to work for all had these. The risk management guy used to show some of the videos; such as a driver falling asleep on the freeway.
There were also many videos of girls going wild. Wink wink nudge nudge.
|
|
|
|
|
PIEBALDconsult wrote: There were also many videos of girls going wild. Wink wink nudge nudge.
This may be OK for a voluntary system, but for a mandatory system - I think that for privacy reasons, the ability to download should be limited to accident-related events.
Unless the "girls going wild" were germane to the accident, it should be irrelevant to law enforcement.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Actually, rather then your vehicle issuing speeding tickets, the car will simply download your entire driving history (since the last download) and some computer will automatically fine you after reviewing what roads you were on, what the posted speed limit is, and what you were actually doing.
But rather than continually fining you, it'll be tied in to a complex point system that will adjusting your insurance and licensing rates, sort of like in The Fifth Element, and if your points exceed a certain monthly quota, your car will simply stop working.
Marc
|
|
|
|
|
While technically feasible, the problem with this system is that all trips - including those where no traffic violations were performed - are available to the licensing authority. This is a serious privacy issue.
Given that the capacity of automotive processors is more than sufficient to run a GPS system, a solution that would preserve the privacy of law-abiding drivers is to have the vehicle download the current speed limits, and record any speeding violations for later review.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
can ayy one help me in video player i wana add video seek bar plz help
|
|
|
|
|
Fast learner, aren't you?
Start with Google.
If that doesn't help try here: Ask a question[^] - but two things:
1) Explain exactly what you have tried, and where you are stuck. The more accurate you are the better the response.
2) Pay attention to what you are doing in future: not bothering to look at instructions which tell you what not to do is a good way to annoy people. Annoyed people do not help as much as happy people...
And don't post questions here again, or I for one will start to consider it as abusive behaviour...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I canna not e. What is video player? Plz hlp. Seek me in bar.
Marc
|
|
|
|