Mathematically defined result of expression

What does it mean mathematically defined result?

There is a quote from 5/4:

If during the evaluation of an expression the result is not mathematically determined or not in the range of representable values ​​for its type, the behavior is undefined.

+4
source share
5 answers

There is a note right after this statement, which gives some types of examples:

[Note: most existing C ++ implementations ignore integer overflows. The processing of division by zero, the formation of the remainder using the zero divider, and all floating point exceptions differ between machines and are usually governed by a library function. -end note]

+5
source

, 0/0 .

1/0 , ++ , .

+4

. : .
, 0, : Division . a \ b=c, b * c=a.
b=0, b 0, , a != 0, c .

, a b , c b * c=a. , . ( ).
"undefined" , . , , . , ", ". , , , "", undefined. . , 0 , .

0

, undefined, .

( , , )

0

" " , . , , - . , , . ++ "" "" .

, , , , , 2+2, , , if the appear requirement .

It is true that it 2+2can be presumably mapped onto various mathematical constructs, not even necessarily related to the statement of Peano arithmetic, but it is not “ordinary” or “ordinary” mathematics according to the standards of the C ++ community.

To answer the question, take an expression and compare it with the corresponding mathematical concept. If it is not defined, then it is not defined.

0
source

Source: https://habr.com/ru/post/1543013/


All Articles