Most voted "float" questions
Float is a type of primitive data that represents a floating point of simple precision at 32 bits. Use this tag for questions that directly involve a given float (such as rounding, converting, formatting, etc.), DO NOT USE simply because it contains a float in your code.
Learn more…128 questions
Sort by count of
-
1
votes2
answers4640
viewsAverage calculation problem between int and float
I’m having a problem with an average calculation. I have a struct with 3 fields. The ones I’m looking for are average product quantity and unit value. I need to average all the products and their…
-
1
votes1
answer495
viewsHow to add two floats interacting with the UI?
I wanted to add two floats, but I put the first decimal number on EditText and when I’m going to add one more decimal number, I put it in EditText milestone in the CheckBox and he continues the same…
-
1
votes2
answers4206
viewsFields aligned in form
Good night, I used float: right;' to put some fields of a form side by side, but they descend a field below. 'Full Name' and 'Date of Birth' should be side by side, but the date field goes down.…
-
1
votes1
answer556
views -
1
votes3
answers481
viewsDoubt with float
#include<stdio.h> int main ( void ){ float y = 12.0809; printf("The number %.2f is a float\n"); return 0; } I know that %.2f is used to consider only two decimal places, but would like to know…
-
1
votes1
answer957
viewsHow exactly do you divide two variables?
In the code below I try to divide the values, but I end up getting a completely wrong answer from the calculation: nota1 = input ("Digite a nota 1: ") nota12 = input ("Digite a nota 1: ") nota2 =…
-
1
votes0
answers55
viewsHow to round float in C without using printf()
I’m not getting round the float to the first two decimal places. I wrote my program like this: float valor; scanf("%f", &valor); printf("valor = %f\n", valor); Once compiled, I typed 573.93 to…
-
1
votes1
answer825
viewsEvaluation activity hours per minutes
Question (2): Make a program that receives an hour formed per hour and minutes (a real number), calculate and show the time typed only in minutes. Consider that: for four and a half (4:30), type…
-
1
votes2
answers7350
viewserror when conver string to float in python
Hello I’m having a problem I’m not getting Contact string to float the program takes the price of a dps game converts to string and position through the character and I am unable to convert price…
-
1
votes1
answer667
viewsHow does the floatval function work?
I saw in the PHP documentation that there is a function called floatval(), to take the floating point value of a variable. Then I saw on the internet a question similar to this one on the internet:…
-
1
votes1
answer6005
viewsTransform all elements of a list into floats
That’s the code I wrote. n_alunos=input('') x=0 idades=[] alturas=[] while x != n_alunos: x+=1 n=raw_input('') a=n.split(" ") idades.append(a[0]) alturas.append(a[1]) How to transform the elements…
-
1
votes1
answer300
viewsConversion of float to string - how to display two or more decimal places?
I have the code below, which returns values of type float. How can I get the result presented to two or more decimal places? private void btnDividirActionPerformed(java.awt.event.ActionEvent evt) {…
-
1
votes3
answers443
viewsGet Integer value in final . 00 and float value in . 01 to 0.9
I have this code below that is a calculator, but I have a problem: I wanted to return a value float when dividing 5 / 2 = 2.5 and returning an integer value when dividing 4 / 2 = 2 and not 2.0! Can…
-
1
votes1
answer78
viewsFastest way to calculate a/b+c/d with float
You can operate four floats in the formula a/b+c/d (two divisions and a sum) mathematically equivalent to the formula (a*d+b*c)/(b*d) (three products, one division and one sum). It is known that…
-
1
votes3
answers431
viewsWhat is the difference between float and float[]?
I’m seeing some codes that some exercises here on the site and whenever I see something I don’t understand, I research. In the case now it was regarding the float[] , What is the real difference…
-
1
votes1
answer1484
viewsHow to read a float with Scanner
My problem is this: package com.vreawillsaveyou01; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); float number =…
-
1
votes2
answers546
viewsPHP adding and subtracting wrong
I have a very strange problem here. It is a code for cash closing, I have the total value of sales, the user informs sales in credit, debit and cash, if the sum of the 3 is equal to the total sales…
-
1
votes1
answer112
viewsHow NOT to round up figures?
I need an exact value but my code always rounds down: float percentageUsed = 6050492416 / 8258998272; System.out.println(String.format("Porcentagem: %.2f", percentageUsed)); In case I had to return…
-
1
votes1
answer204
viewserror in a real-to-dollar python converter exercise
Hello, I’m trying to make a converter from real to dollar and to normal values it works but is giving error when I put the dollar*N10, type 420 real, or 840, it is left the exact value of the…
-
1
votes0
answers31
viewsWhy (0.1 + 0.2 - 0.3) is 5.55111512313e-17?
It seems pretty obvious to us humans that 0.1 + 0.2 - 0.3 is 0 but why when I ask the Python interpreter to perform the following operation: print(0.1 + 0.2 - 0.3) he returns 5.55111512313e-17? It’s…
-
1
votes1
answer53
viewsWhy when I put float right the color of my background disappears?
I created a header, with a background, text and image. I want to leave the text on the left and the image on the right. I put the float:right but then the bottom ends up disappearing. .fundo1 {…
-
1
votes0
answers25
viewsRelate String matrix to a Float vector in C
I need the program to receive 20 names typed by the user, store in a Char Matrix, and right after receive the 20 salary of the users and store in a Float vector. I was able to do even the part where…
-
0
votes1
answer224
viewsError reading %f and %e from a file in C
In the following excerpt of my code I have to read a function of a txt file and extract its coefficients. When I set the coefficients as integers and read them with %d works correctly, but when…
-
0
votes1
answer98
viewsDiv with float does not adjust the grid
I’m developing a website and it should list some specifications of a system. There are several lists of varying heights. Problem: I use the float: left in all lists. I expected the lists to adjust…
-
0
votes1
answer267
viewsUsing double type in c++ can be "faster" in terms of running time than using floats?
I have a program developed in c++ in visual studio, which processes a huge amount of data! This program can use both float and double type data, and this specification is made as follows: typedef…
-
0
votes1
answer1020
viewsCalculate the number of hours between two hours and turn into float
I needed to create a function that received two hours in the format (00:00:00), calculate the number of hours between them, and convert me to float. However the float would be of this genre:…
-
0
votes0
answers80
viewsAligning elements side by side correctly
I’m not being able to align elements side by side correctly To Div feels like I’m with Height: 0; Just recognizing the height of the element without the Float: left; HTML The first is how it turned…
-
0
votes1
answer540
viewsProgram to calculate media
#include <stdio.h> #include <stdlib.h> int main() { int sum = 0; int times = 0; int number; int average; while ( number != 9999 ){ printf( " Type the number and i will make the average,…
-
0
votes1
answer361
views -
0
votes0
answers44
viewsHow to obtain exact results from simple arithmetic calculations?
I tested simple arithmetic calculations in multiplex languages. I tested some calculations in python console: >>> 0.1+0.1 0.2 >>> 0.1+0.2 0.30000000000000004 >>> 10*0.67…
-
0
votes1
answer543
viewsProblem with float and matrix
I have to add the values that have two or more decimals but when I put by Exp: "1.0", it fills this whole row automatically and jumps to the next, I reviewed and I don’t know why you are giving…
-
0
votes1
answer856
viewsexercise Floating point error
I have a list of floating point errors and am having some difficulty with one of the questions. If anyone can help me, I am grateful. For the code below, I need to justify the reason for the error.…
-
0
votes1
answer911
viewsPDO SQLSTATE[07002]:COUNT field incorrect or syntax error
I’m having trouble making a decrease in sql with Pdo. I’m getting the following error SQLSTATE[07002]: [Microsoft][ODBC Driver 11 for SQL Server]COUNT field incorrect or syntax error code <?php…
-
0
votes1
answer401
viewsFloat variable with 2 digit accuracy after the comma in sql oracle
How do I create a float variable with 2 digit accuracy after the comma in a table in SQL/Oracle. From now on, thank you.
-
0
votes1
answer30
viewsI can’t get an element to wrap in a responsive layout
Good afternoon, I’m trying to make a layout responsive but I can’t get the product description to go under the image when the available space is too small. I tried with display:flex and float but…
-
0
votes1
answer1522
viewsChange number of digits after comma depending on the situation
I know I can get a limit of digits after the comma with %.2f for float and %.2lf for double. How can I change this limit depending on the occasion? For example: Get a two-digit limit with float that…
-
0
votes0
answers111
viewsWorking with pennies in C
In the code below I can receive values in the pay fields without cents (example: 1,800), but if I put (1,800,20) has error. Detail I’m using setlocale(LC_ALL,"Portuguese"); . printf("\nAntepenúltimo…
-
0
votes1
answer224
viewsWhy does the variable x of the double type always print the same WRONG value in scientific notation?
In this first example I would like to know why the variable x read in double, when it is formatted by the function "printf()" does not display the value correctly, and every time the value is the…
-
0
votes2
answers44
viewsProblem with form formatting
Good morning guys, I have a certain problem in the newsletter form of my site. I have done several researches trying to solve the problem, but the lack of knowledge of the area I think is making me…
-
0
votes2
answers2255
viewsHow to get the rest of a float number in C?
This is the question of the URI I thought of this idea more when I’m going to take the rest of float numbers I can’t... #include <stdio.h> int main(int dinheiro) { int res, res2; Here I have…
-
0
votes1
answer368
viewsFormatting of float types
I did a little research before I asked, can you tell me why it doesn’t show 2,500 on the way out, but 2.5 salario=float(input("Digite seu salario")) print(salario)
-
0
votes1
answer90
viewsProblem with css float
We created this code below to simulate the same problem on a site I’m developing to practice my html and css. I have two elements that float to the left and one to the right but when I clear the…
-
0
votes3
answers1982
views"for" with step "float": Typeerror: 'float' Object cannot be Interpreted as an integer
I want to loop 0 to 100 with step 0.1: for x in range(0, 100, 0.1): a = cos(radians(x)) But I get this mistake: Typeerror: 'float' Object cannot be Interpreted as an integer How can I make a loop…
-
0
votes1
answer180
viewsFast calculation of square root and its multiplicative inverse in float
Knowing the algorithm "0x5F3759DF" (or "fast inverse square root"), we easily imagine a gross number of variants of it to calculate square root and inverse multiplicative of it in single-Precision…
-
0
votes1
answer2656
views -
0
votes1
answer143
viewsWhy do these two identical codes, one in C++ and the other in Java, give different results?
I’m trying to solve an issue in the URI Online Judge in Java but I’m afraid of 5% error, and what I’ve studied is being caused by the fact that the accuracy of variables in C++ and Java is…
-
0
votes1
answer55
viewsProblem with jquery percentage calculation
Good afternoon , I’m having trouble calculating percentage, but the error does not occur in the mile up, anyone has any idea what may be? var cost_value = $('#cost_value').val().replace('.',…
-
0
votes2
answers453
viewsIs it possible to return a float value with 2 decimal places to end 0?
I am pushing to be fed in Google Analytics and one of the guidelines that the prices are returned as float, so far all well managed to solve using parseFloat(), however, they need two decimals up to…
-
0
votes1
answer141
viewsProblem with PHP numbers
I have the following exercise in PHP: The cost of a new car to the consumer is the sum of the factory cost with the percentage of distributor and taxes (applied at the cost of factory). Assuming the…
-
0
votes2
answers284
viewsSQL Oracle - Clob to Number
I have a table which does not have to be remodeled, it is composed by a CLOB field which has decimal values separated by point ex:(123.12) I need this field to be returned to me in the result as a…