question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Negative numerics issue

See original GitHub issue

Description

Hi, I found an issue with negative numerics. Could you fix it please?

Steps to reproduce

  1. Create test table CREATE TABLE tmp_DecimalTest ( FixedDateDate,Amount1Decimal(16,4),Amount2Decimal(20,8),Amount3 Decimal(22,10) ) ENGINE = MergeTree PARTITION BY toYYYYMM(FixedDate) ORDER BY FixedDate SETTINGS index_granularity = 8192;

  2. 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;
    }
}

} `

  1. Check table data. Fields Amount2 and Amount2 have wrong value (see attachement)

decimal issue

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
killwortcommented, Oct 19, 2020

1.2.5 fixes even smaller errors in numerics representation.

1reaction
killwortcommented, Aug 31, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found