math - Divide by Zero: Infinite, NaN, or Zero Division Error? -


why isn't 1/0 == inf in every language? not mathematically correct response?

all languages i'm familiar capable of expressing both infinite , nan values, why choose throw error or return nan instead? make life harder scientific application developers? ;-)

update: should maybe close question because incorrectly thought 1f/0f == float.nan in java. wrong: does correctly return float.infinity. main confusion; fact languages throw errors instead understandable, long no language returns nan.

apart fact 1 / 0 == inf mathematically highly questionable, simple reason why doesn’t work in programming languages 1 / 0 performs integer division universally (exceptions exist).

the result integer, , there no way of encoding “infinity” in integer. there floating point numbers, why floating-point division yield infinite value in languages.

the same true nan: while ieee floating point standard defines bit pattern represents nan value, integers don’t have such value; such values cannot represented integer.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -