Negative numerics issue
See original GitHub issueDescription
Hi, I found an issue with negative numerics. Could you fix it please?
Steps to reproduce
-
Create test table
CREATE TABLE tmp_DecimalTest (
FixedDateDate,
Amount1Decimal(16,4),
Amount2Decimal(20,8),
Amount3Decimal(22,10) ) ENGINE = MergeTree PARTITION BY toYYYYMM(FixedDate) ORDER BY FixedDate SETTINGS index_granularity = 8192;
-
Fill the table using code below: `using ClickHouse.Ado; using System; using System.Collections; using System.Collections.Generic;
namespace ClickHouseDecimalTest { class Program { private static string _connectionString = “************************;”;
static void Main(string[] args)
{
var list = new List<MyPersistableObject>();
list.Add(new MyPersistableObject()
{
MyDateField = DateTime.Now,
MyDecimalField1 = (decimal) -100.0,
MyDecimalField2 = (decimal) -100.0,
MyDecimalField3 = (decimal) -100.0,
});
var connection = new ClickHouseConnection(_connectionString);
connection.Open();
var command = connection.CreateCommand();
command.CommandText = "INSERT INTO tmp_DecimalTest (FixedDate,Amount1,Amount2,Amount3) VALUES @bulk";
command.Parameters.Add(new ClickHouseParameter
{
ParameterName = "bulk",
Value = list
});
command.ExecuteNonQuery();
}
}
class MyPersistableObject : IEnumerable
{
public decimal MyDecimalField1;
public decimal MyDecimalField2;
public decimal MyDecimalField3;
public DateTime MyDateField;
public IEnumerator GetEnumerator()
{
yield return MyDateField;
yield return MyDecimalField1;
yield return MyDecimalField2;
yield return MyDecimalField3;
}
}
} `
- Check table data. Fields Amount2 and Amount2 have wrong value (see attachement)
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Algebra Topics: Negative Numbers
Another important thing to know about negative numbers is that they get smaller the farther they get from 0. On this number line,...
Read more >Pre-Algebra : Negative Numbers
Negative Numbers : Example Question #2 The problem indicates that the result is units more negative than , which is .
Read more >HSPT Math : Negative numbers
A negative number taken to the power of a positive integer can be either negative or positive depending on whether the exponent is...
Read more >The History of Negative Numbers - NRICH
The ancient Greeks did not really address the problem of negative numbers, because their mathematics was founded on geometrical ideas.
Read more >Negative number
Negative numbers are used to describe values on a scale that goes below zero, such as the Celsius and Fahrenheit scales for temperature....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
1.2.5 fixes even smaller errors in numerics representation.
Well, there was an error for the negative decimals larger than 8 bytes. I’ve fixed that, will be released with v.1.2.3