c - Why isn't there a round()-type function that returns an int? -


The C standard library defines a bunch of spherical functions. Originally there are two "full" families,

  • print:

      double holes (double x); Float quintro (float x); Long double double arctic (long double x); / / / Printing point current logic direction uses a long int lint (double x), in the floating-point form an integer value // rounds its argument; Long int lintif (float x); Long interval Little (Long Double X); Longer than the only Larring (Double X); Long-term lolin (float x); Laurentl long (long double X) long; // Lint and Lirin do the rounds on their logic / second closest integer values, round the current / spherical direction. If the round value is outside of // // return type, the numerical result is unspecified and may be a domain // error or category error. *  
  • round:

      double round (double x); Float round (float x); Long double round (long double x); // Round Functions in the round of the nearest integer value / Floating-Point format, regardless of the current circular direction, making the case of halfway away from zero, // long interval width (double X); Long interval flight (float x); Long interval long (long double x); Long time full time (double X); Intel Longiff (Float X) for a long time; Long-term interval (long double x); // The line and the loud function, round their arguments in the nearest // integer value, removing halfway cases by zero, // regardless of the current rounding direction. If the round value is outside the // return type limit, the numeric result is unspecified and may be a domain error or a category error.  

However, there is apparently no difference which can be found in the round () or rint () And a int , eg:

  int iround (double D); Int iRORF (float F); Intraindrial (Long Double L); Int'lIrint (double D); Int IRIN (Float F); Intintl (long double l);  

I understand that one concern can be that int is not able to properly express the values, but the same argument very well < Code> long interval (maximum value for a float is ~ 10 ^ 1 tall int , versus ~ 10 ^ 128). Does anyone know why the standard does not define such rounding functions?

Why is not a goal () - the type of work that gives an integer?

Because l * -functions have been covered by the i * functions' functionallity.

The follow-up question is:

We have the l * function because we have the ll * function ?

The answer is that C99 added the new long time data type, related to the new library functions.

C90 for integer integer already

  • Lint (*)
  • I

    new function

    • llrint * ()
    • llround * ()

    was introduced.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -