# All Questions

Tagged with floating-point mysql

33
questions with no upvoted or accepted answers

2votes

2answers

61views

### How does MYSQL represent floats internally?

I ran into this issue wherein inserting a number like 1234567 to a float column leads to a rounded off value of 1234570.
I understand that this is due to float point precision but what confuses me is ...

2votes

0answers

657views

### What MySQL "DECIMAL" precision and scale is required to store a C# decimal value?

I want to store some decimal values in my MySQL database. The obvious MySQL database type for that would be DECIMAL I guess.
What precision "a" and scale "b" do I have to set for DECIMAL(a,b ) ...

2votes

0answers

2kviews

### How does we understand this float-point numbers (.1E0)

It is about data types in mysql and floating-point values, but I don't understand that format.
example: .1E0
I know E means *10
what does means the 0 there?
What number that represent?
another example:...

2votes

0answers

1kviews

### Truncate (not round) decimal in SQL

I'm doing astored procedure using a MySQL database.
How could I round or truncate a FLOAT variable with diferent decimals?
I've found this answer: Truncate (not round) decimal places in SQL Server
...

1vote

1answer

99views

### Insert FLOAT values into mysql table

I am trying to insert values of type FLOAT into a table using (the C++ connector is in use)
res = stmt->executeQuery("INSERT INTO `ticker_info`(`a1`,`a2`,`a3`,`b1`,`b2`,`b3`,`c1`,`c2`,`v1`,`v2`...

1vote

0answers

69views

### Reconciling inconsistent floating precision from query in ruby on rails

When I run a query like:
ActiveRecord::Base.connection.select_rows(
"select score, coalesce(null, score), score * 1.0"\
" from table limit 1"
)
enter code here
I get back a result like:
[[805....

1vote

0answers

43views

### How to convert single precision floats saved as tinyblob back to single floats in MySql?

In my MySQL table I have a field named A of type tinyblob. Data in every row is as long as 8 bytes. In these 8 bytes I store sequentially two single numbers.
This is how I convert these two numbers ...

1vote

1answer

204views

### MySQL location select query returns 0 in stored procedure

Can anybody spot the problem here?
I have a stored procedure I wanna use to find closest locations to a specific location.
When I try the select outside of a stored proc (just in a query window) all ...

1vote

0answers

1kviews

### mysql float data type round off's values after 6 decimal places

I have a table (say table1) with one field of data type float (say field1). The values in this field are all unique with upto 8 decimal places.
I executed following queries on this table:
SELECT ...

1vote

1answer

359views

### ASP.Net: Google Maps + store Float in MySQL --> Comma not point?

I'm trying to add google maps coordinates to a float field, but I think due to my character coding (Belgium) it's not taking dots. I've set my field to "float", but it keeps changing the coordinate "...

0votes

0answers

26views

### Java's Double.doubleToLongBits equivalent in MySQL

Suppose number: -58.725. When calling Double.doubleToLongBits(-58.725) it returns: -4589910410541609779. How can i get the same result in MySQL?
I have tried: CONV(CONV(-58.725, 10, 2), 2, 10) which ...

0votes

0answers

225views

### Floating point precision in MariaDB using python mysql connector

I am new to python & MariaDB and wonder that all float types in all my MariaDB tables lack precision. Here's an example: I create a table in MariaDB with four different data types float, double, ...

0votes

1answer

61views

### MySQL - using float in function

I have this function:
CREATE FUNCTION `calculateSalary`(workDays INT, daysWorked INT, salary DECIMAL) RETURNS DECIMAL DETERMINISTIC
BEGIN
DECLARE handSalary DECIMAL;
DECLARE fullSalary DECIMAL;
SET ...

0votes

0answers

93views

### insert json file data to mysql database, having problem with "FLOAT" data type

I have a ".json" file that simply has the data of some products. this is the file:
[
{
"product_name": "TV Sony A8H 55 Inch",
"company": "Sony",
"price": 1698....

0votes

3answers

441views

### Transform/Convert Scientific Notation [From Varchar to Decimal/Numeric] in SQL

I have a table where one of columns carries values as below. The datatype of the column is in VARCHAR. Now, for the sake of customer experience, I have to convert the below values to actual non-...

0votes

0answers

70views

### mysql - FLOAT storage size switches from 4 to 8 bytes when the precision is 24 or 25?

really a tiny inconsistency, but still - the mysql 8.0 doc says that:
A precision from 0 to 23 results in a 4-byte single-precision FLOAT column. A precision from 24 to 53 results in an 8-byte double-...

0votes

1answer

27views

### What will be the constraints of the values that can be entered in the colum that was declared as FLOAT?

I am building a web app, and in some section in it a teacher inserts the expected results of a scientific experiment. These results must be very accurate, they might come like this 0.4933546522886728. ...

0votes

1answer

38views

### SQL float columns: select "where x = 2.0" works, but "where x = 2.1" does not

I have a Ruby on Rails app with a model Project, which has an attribute wcag_version of type float.
I have a record with wcag_version = 2 and one with wcag_version = 2.1:
What I noticed is that ...

0votes

0answers

582views

### Python: mysql double and float

In MySQL table column balance has a type DOUBLE without specifying precision. And I can't change column type to DECIMAL or DOUBLE with precision (I know that is epic fail to store money in DOUBLE ...

0votes

2answers

222views

### Split MySQL value into integers

I try to load a (biggish) csv into a table. I use:
LOAD DATA LOCAL INFILE
'C:\\ProgramData\\MySQL\\MySQL Server 5.7\\Uploads\\xxxx.csv'
INTO TABLE xxx
FIELDS TERMINATED BY ','
OPTIONALLY ...

0votes

1answer

872views

### Data truncated for column when using FLOAT in GUI

I am using a video course on database programming with the current lesson being using Java to connect to MySQL. I have followed the video, and even copied the text working file for this particular ...

0votes

1answer

79views

### Setting spatial precision in Mysql

For my application I have to store coordinates ,so I decided to use POINT type. My app only needs precision up to 4 digits so the question is: Can I change the precision of a POINT or could I use ...

0votes

0answers

38views

### Why is floating point value saved incorrectly in MySQL?

We saved a value of 2.01 in a float column in MySQL.
Then, after we applied the avg function, it returned 2.009999990463257
Why is this happening?
Here is the query we are using:
SELECT avg(height)...

0votes

0answers

46views

### How are are data types extended and converted in operations in mysql/sql?

I am not clear how the mathematical operations are done in SQL.
For example in Java the numbers are "extended" to integers before applying an operation and when the other operand is of higher type or ...

0votes

1answer

925views

### Coordinates as primary key

I have a table which stores some POIs, so it has some id, name, latitude and longitude. The problem is, that I don't want to have the POIs with same coordinates in the database twice. The ...

0votes

1answer

101views

### price column in dollar and dinar

I have a price column which maybe include 100.00 which is in dollar or 100.000 which is in Iraqi dinar .
I can't use decimal(10,3) or decimal (10,2) because it is not fixed
Please, how can I do that ?...

0votes

1answer

1kviews

### Hibernate addScalar to Hibernate.FLOAT round off

Query qry = session.createSQLQuery(qrystr)
.addScalar("id", Hibernate.INTEGER)
.addScalar("balance",Hibernate.FLOAT);
Object[] headerDetails=(Object[])qry.uniqueResult();
session.close();
...

0votes

1answer

404views

### Sorting and Indexing Rank as Bigint or Float

Using MySql. I have a table of users and need to store user's rank in one of the columns. The application determines the rank and it happens to be a signed float. Example of ranks would be:
7732....

0votes

0answers

378views

### Comparing float value in cakephp find statement

This code is to count the number of students getting fever in class. Assumming that a person gets fever if the temperature is >=38.1 deg.
$count = $this->TemperatureRecords->find('count',array('...

-1votes

0answers

28views

### Laravel decimals; 55.0 Inserting into MySQL as 54 every time

I have two variables in PHP
$current_price = 110.0;
$coupon_discount = 55.0;
I create a new variable $discounted_price
$discounted_price = $current_price - $coupon_discount // 55.0
Dumping out the ...

-1votes

2answers

82views

### where clause to get records which matches upto 2 decimal

I have table containing following values:
colname:
28.54617,
28.54917,
98.54617,
48.54217,
28.54217
How can I write condition in where clause to fetch all records which match up to two decimal
so here ...

-1votes

1answer

86views

### Float representation, integer bits and fraction bits

How 8 integer bits and 2 fraction bits, i.e. 00011001 and 10 means 25.75? Considering 2s complement format encoding.
Where do I have to begin in order to tackle this issue?

-2votes

2answers

848views

### MySQL rounding of Float Data type

set up a table in mySQL with a column FLOAT(2,2), then tried to insert 10 and it diaplayed 0.99?