c++ - Do gcc's __float128 floating point numbers take the current rounding mode into account? -


do arithmetic operations on gcc's __float128 floating point numbers take current rounding mode account?

for instance, if using c++11 function std::fesetenv, change rounding mode fe_downward, results of arithmetic operations on __float128 rounded down?

is guaranteed __float128 specification?

i believe guaranteed operations on __float128 take rounding mode account.

according gnu c library documentation floating-point calculations respect rounding mode.

according gcc manual __float128 floating type supports arithmetic operations division etc.

from deduce, operations on __float128, rounding mode has be taken account.

the gnu c library documentation states:

20.6 rounding modes

floating-point calculations carried out internally precision, , rounded fit destination type. ensures results precise input data. ieee 754 defines 4 possible rounding modes: [...]

reference: http://www.gnu.org/software/libc/manual/html_node/rounding.html

the gcc manual states:

6.11 additional floating types

as extension, gnu c supports additional floating types, __float80 , __float128 support 80-bit (xfmode) , 128-bit (tfmode) floating types. support additional types includes arithmetic operators: add, subtract, multiply, divide; unary arithmetic operators; relational operators; equality operators; [...]

reference: https://gcc.gnu.org/onlinedocs/gcc/floating-types.html

working example

example code , output

__float128 f1=1.0; __float128 f2=3.0;  char buf[256];  fesetround(fe_downward);  quadmath_snprintf (buf, sizeof buf, "%*.34qf",10, (f1/f2)); printf ("%s\n", buf);  fesetround(fe_upward);  quadmath_snprintf (buf, sizeof buf, "%*.34qf",10, (f1/f2)); printf ("%s\n", buf); 

outputs:

0.3333333333333333333333333333333333 0.3333333333333333333333333333333334 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -