All Questions

Tagged with
33 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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 ...
user avatar
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 ) ...
user avatar
  • 5,504
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:...
user avatar
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 ...
user avatar
  • 131
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`...
user avatar
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....
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 1,880
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 "...
user avatar
  • 11
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 ...
user avatar
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, ...
user avatar
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 ...
user avatar
  • 21
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....
user avatar
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-...
user avatar
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-...
user avatar
  • 4,037
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. ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 109
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 ...
user avatar
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 ...
user avatar
  • 5
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 ...
user avatar
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)...
user avatar
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 ...
user avatar
  • 17.8k
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 ...
user avatar
  • 1,201
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 ?...
user avatar
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(); ...
user avatar
  • 1,799
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....
user avatar
  • 4,985
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('...
user avatar
  • 953
-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 ...
user avatar
-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 ...
user avatar
-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?
user avatar
  • 53
-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?
user avatar