Good, doubt noob real numbers [closed]

-1

Good I wanted to ask how, after having carried out operations with real numbers, for example 100 - 1.5 = 98.5;

How could I be left alone with 98?

    
asked by Alejandro Rebolo 08.06.2018 в 21:53
source

2 answers

1

The easy way is to use a rounding function.

In language C, you must include the library math.h and the syntax is round(x)

    
answered by 08.06.2018 / 22:01
source
-1

You could take the value and make a split by point in the first position you will have the 98 and in the second the 5.

Another option is to convert the result to an integer:

Example: In java

int valor1=100;
Double valor2 =1.5;
int valor=(int) (valor1-valor2);

System.out.println(valor);

Result: 98

    
answered by 08.06.2018 в 22:01