About C Floating point digital inputs and outputs

Updated on technology 2024-04-19
14 answers
  1. Anonymous users2024-02-08

    chopping | rounding

    Floating-point numbers are like sand in your hands, always inadvertently trying to flow away a little.

    Therefore, when comparing floating-point numbers, you generally don't use == directly, but use it.

    fabs(a-b) < e considers a and b to be equal, where e is a relatively small number, also known as an error bound.

  2. Anonymous users2024-02-07

    The float type has 6 decimal places by default.

  3. Anonymous users2024-02-06

    #include

    void main(void){

    float score;

    scanf("%f",&score);

    printf("%.3f",score);Control the output format.

    You can control the output format when using printf output, and if you want to know how the computer is organized, you can look at the composition principle, how the floating point number is represented in memory. There is a ** description above, and it can only be expressed in words here, and it is not clear!

  4. Anonymous users2024-02-05

    Floating-point numbers are inaccurate.

    Floating-point arithmetic refers to operations in which floating-point numbers are involved, often accompanied by approximations or rounding because they cannot be represented exactly.

    For example, a 4-digit decimal floating-point number with an exponential range of 4 can be used to represent 43210, or, but not with sufficient precision to represent and must be approximated as and 43210). Of course, the actual number of digits used is usually much greater than 4.

  5. Anonymous users2024-02-04

    This is inseparable from the hardware of the computer, and of course the software. If you're just learning C, there's no need to spend too much time on this issue.

  6. Anonymous users2024-02-03

    Use the output format specifier to specify the exact number of decimal places.

    For example: void main().

    float a=;

    printf("%3f", a) ;

    of which %The 3 in 3f means that the output is accurate to 3 decimal places.

    So the referential form is printf("%",p);, specifying that the output data occupies a total of m columns, where n digits are decimals. If the length of the value is less than m, fill in the space at the left end, and if the length of the value is greater than m, it will be output according to the actual number of digits.

  7. Anonymous users2024-02-02

    You can specify the output format specifier to a certain number of decimal places.

    For example: printf("%", output (where represents a space).

    The parts in the output format specifier % above mean as follows:

    2 – indicates that the integer part is output at a fixed 2-bit width. If the number of digits of the data is less than 2, the left end is filled with a space, and if it is greater than 2, it is output according to the actual number of digits.

    3 - (3 is preceded by a decimal point) means that the output is accurate to 3 decimal places. If the actual number is less than 3 digits, 0 will be added at the end, and if it is greater than 3 digits, the first three digits will be rounded.

  8. Anonymous users2024-02-01

    % minimum domain width m

    When the precision n:%f,%e,%e, the number of decimal places is displayed.

  9. Anonymous users2024-01-31

    printf("%.2f',v);

    2f,.2 refers to the output to several decimal places.

    Fill in the exact digits.

    Point a few "f."

  10. Anonymous users2024-01-30

    Your questions look simple, but it takes a lot of time to do, I have debugged these questions, you can debug it yourself, I don't know if it can meet your requirements, haha!

    #include

    void main()

    Procedure***

    void main()

    for(i=0;i<3;i++)

    #include

    void main()}

    #include

    void main()

    #include

    #define n 5

    struct student

    stu[n];

    void main()

    printf("");

    print(stu);

    void print(struct student stu[6])

  11. Anonymous users2024-01-29

    printf("%.nf",p);

    p variable, n exact number of digits, n is generally not more than 6, greater than 6 is generally not exact.

  12. Anonymous users2024-01-28

    You're going to lose a lot of money, and you're going to use it in **.

  13. Anonymous users2024-01-27

    m is an integer, m 2 is an integer operation, m 2 = 7 2 = 3n, a and b have a real form, n*a b is a real operation, 4*1 2 is an integer operation, and 1 2 = 0

    x=3+24+0=27

    There is no limit to the floating-point number output format, and the value of x is output to 6 decimal places, and b is selected for output

  14. Anonymous users2024-01-26

    You can use the output format specifier to specify exactly to the last few decimal places.

    For example: printf("%5f", output (where represents a space) above the output format specifier %The parts in 5f are as follows:

    f floating-point number;

    5"—5 is preceded by a decimal point) means that the output is accurate to 5 decimal places. If the actual number is less than 5 digits, 0 will be added at the end, and if it is greater than 5 digits, the first 5 digits will be rounded.

Related questions
5 answers2024-04-19

include header files

main ( *main function*.) >>>More

9 answers2024-04-19

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

11 answers2024-04-19

Valid variable names for the C language:

First, it can only contain numbers, letters, and underscores. >>>More

15 answers2024-04-19

ints need to be expressed according to the size of the compiler. >>>More