Questions tagged as 'float'

4
answers

Mathematical division needs

On the Windows calculator: 9 / 3,0001 = 2,999 ... In my program: 9 / 3,0001 = 3; I would like to get this level of precision using C. See excerpts from my program: double op(double num1, double num2, char c) { if(c == '/')...
asked by 25.10.2014 / 18:23
2
answers

Float decimal places

I'm developing an application to track product sales. However, sometimes the added value of reports does not beat the decimal places. It gives small differences. How do float stop giving these problems? I always use only two decimal place...
asked by 11.11.2014 / 13:02
1
answer

JavaScript generating float with several decimal places

When creating an ordering system (quantity x value) I noticed that in some cases when adding broken values, JavaScript returns numbers with many more decimal places than expected. Example: (123*1.23)+(312*3.26) //retorna 1168.4099999999999...
asked by 17.08.2014 / 21:18
2
answers

What kind of data (double, float) should I use when representing a temperature?

My question is regarding the use of Double and Float in Java exercises when having to declare a temperature (Celsius scale). Which one should I use in this case? I declare as Double , but the teacher correcting the exercis...
asked by 07.09.2018 / 21:00
4
answers

Converting float to char array in C / C ++

Recently I ran a test and there was an issue that asked for a number like 123.456 to be displayed as 321.456 . I thought the best solution would be to convert this to an array of char and then create an algorithm to print pos...
asked by 03.04.2014 / 18:42
2
answers

Error: object of type 'float' has no len

I was debugging simple operations in the Python interpreter, and the following command made me curious: >>> b = 3.12; len(b) With the following error:    Traceback (most recent call last):       File "", line 1, in       Type...
asked by 05.01.2016 / 22:50
2
answers

What does float ("NaN") and float ("inf") mean in Python?

I've seen a code like this: def _min(*args): res = float('inf') for value in args: if value < res: res = value return res I would like to know what is a float ("inf") and a float ("NaN").     
asked by 07.04.2018 / 03:01
1
answer

Float rounding in C

I need to return a value float with 1 decimal place, however it is returning with the value rounded. I have the following code: float n1 = 4; float n2 = 9; float total = n2 / n1 ; printf("Media: %.1f ", total ); //aqui, o resultado é 2....
asked by 23.05.2014 / 20:21
1
answer

Mathematical operations on ARM-M4 lock when PWM interrupt is on

When I turn off the timer overflow interruption of PWM (+ - 15Khz) operations occur normally. But when it's turned on the processor gets lost in floating-point operations. I follow the debug in step mode but at some point the debug does n...
asked by 08.04.2014 / 20:48
2
answers

How to limit decimal numbers in Python?

How do I format a decimal number in Python for a given amount? For example, I want to display only two decimal places of the following number: numero_decimal = 3.141592653589793 How could I turn this number to 3.14 ?     
asked by 09.01.2017 / 19:51