Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / 0 devide by 0 give -nan(ind)

Author
Message
Chmava
11
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 10th Aug 2024 09:08 Edited at: 10th Aug 2024 09:14
Does anyone know why 0.0 divide by 0.0 give something that is not a number?



It return something like "-nan(ind)"
Any idea how to fix it?

any help appreciated!
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 12th Aug 2024 07:13 Edited at: 12th Aug 2024 07:14
because the result of dividing zero by zero is not possible. even the calculator on windows will say not defined, python and java and c++ will give a null and or divide by error error or crash. You can tell a program to return a zero if there is a zero division and you can catch it before it happens using a lexer /parser or exception. Even simple math how many time will zero go into zero? you might think 1 but no u cant put nothing in nothing. if oyu want to fix it if divided <>0 then print (a/b) else print "divide by zero error"

MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 31st Aug 2024 08:25
In EVERY good programming language, it gives you a compile or runtime time error that division by zero is not possible.

@Chmava: Do an IF check on your divisor if you don't know the value upfront.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 10th Sep 2024 00:07
Division by zero has been undefined behaviour in mathematics since the invention of zero in the 6th century, its a fundamental baseline rule, division by zero is forbidden!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee

Login to post a reply

Server time is: 2024-11-17 22:33:03
Your offset time is: 2024-11-17 22:33:03