Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:46:24+00:00 2026-05-27T16:46:24+00:00

I have an application that computes a value of -1407.858; the C# data type

  • 0

I have an application that computes a value of -1407.858; the C# data type for this is decimal.

The column data type in the database is decimal(12,2). I would’ve thought it’d round the value and insert -1407.86 (which would satisfy both away from zero rounding and to even rounding).

Unfortunately the value is being inserted as -1407.85. The only explanation I can come up for this is that the last digit is being truncated.

I have done some simple test queries in SQL Server such as:

declare @first AS decimal(12,2)
declare @second AS float --[or decimal(12,3)]

set @second = -1407.858
set @first=@second

select @first;

And I get back -1407.86, so I suppose SQL Server automatically rounds values when it’s setting them, but not when inserting them. Is this correct? Does SQL Server only truncate when inserting, but round when setting?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:46:25+00:00Added an answer on May 27, 2026 at 4:46 pm

    I did a test with Linq2sql, with the following situation:

    • Mapped a table with a int primary key, and a decimal(12,2) field;
    • Inserted a item with the value -12.585;

    Executing SQL Profiler, I realized linq2sql has truncated the value, sending the following statement to server:

    exec sp_executesql N'INSERT INTO [dbo].[TestNumbers]([Id], [Number1])
    VALUES (@p0, @p1)',N'@p0 int,@p1 decimal(12,2)',@p0=0,@p1=-12.58
    

    So you are facing a linq2sql bug. You should round your numbers before you send them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that computes the absolute value of a custom value type: public
I have a .net application (c#) that goes something like this public partial class
Currently I have an application that takes information from a SQLite database and puts
I have an application that is used on several hundred computers across the company
We have a web application that manages inventory for our computer support group. One
I have an MFC application that runs on my computer, but when I try
I have a desktop application that needs to upload/download images to/from service computer over
I have a .net application that is not working on a colleagues computer (he
I have a MFC application that launches a IWebBrowser2 window. On users computers where
I have been recently trying to deploy a C# application on a computer that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.