Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Division by zero
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Integer arithmetic === [[File:TI86 Calculator DivByZero.jpg|thumb|Handheld calculators, such as this [[TI-86]], typically halt and display an error message after an attempt to divide by zero.]] [[Integer (computer science)|Integer]] division by zero is usually handled differently from floating point since there is no integer representation for the result. [[Central processing unit|CPUs]] differ in behavior: for instance [[x86]] processors trigger a [[Interrupt|hardware exception]], while [[PowerPC]] processors silently generate an incorrect result for the division and continue, and [[ARM architecture family|ARM]] processors can either cause a hardware exception or return zero.<ref>{{citation |title=Divide instructions |work=ARMv7-M Architecture Reference Manual |publisher=Arm Limited |url=https://developer.arm.com/documentation/ddi0403/d/Application-Level-Architecture/The-ARMv7-M-Instruction-Set/Data-processing-instructions/Divide-instructions |access-date=2024-06-12 |edition=Version D |year=2010 }}</ref> Because of this inconsistency between platforms, the [[C (programming language)|C]] and [[C++]] [[programming language]]s consider the result of dividing by zero [[undefined behavior]].<ref> {{cite conference |mode=cs2 |last1=Wang |first1=Xi |last2=Chen |first2=Haogang |last3=Cheung |first3=Alvin |last4=Jia |first4=Zhihao |last5=Zeldovich |first5=Nickolai |last6=Kaashoek |first6=M. Frans |contribution=Undefined behavior: what happened to my code? |title=APSYS '12: Proceedings of the Asia-Pacific Workshop on Systems |conference=APSYS '12, Seoul, 23β24 July 2012 |location=New York |publisher=Association for Computing Machinery |isbn=978-1-4503-1669-9 |doi=10.1145/2349896.2349905 |doi-access=free |hdl=1721.1/86949|hdl-access=free }}</ref> In typical [[high-level programming language|higher-level programming languages]], such as [[Python (programming language)|Python]],<ref>{{citation |title=Python 3 Library Reference |chapter=Built-in Exceptions |chapter-url=https://docs.python.org/3/library/exceptions.html#ZeroDivisionError |publisher=Python Software Foundation |at=Β§ "Concrete exceptions β exception <code>ZeroDivisionError</code>" |access-date=2024-01-22 }}</ref> an [[Exception handling (programming)|exception]] is raised for attempted division by zero, which can be handled in another part of the program.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)