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 8165227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:29:17+00:00 2026-06-06T19:29:17+00:00

I have a class with a decimal property & I’m serializing & deserializing using

  • 0

I have a class with a decimal property & I’m serializing & deserializing using JSON.NET. The problem I’m having is that if say the decimal value is 100000000000023063.0 , when I deserialize it gets converted to 100000000000023000. I have checked the JSON & it’s definitely recorded as 100000000000023063.0.

I’ve looked into it &

decimal.Parse("100000000000023063.0")

=

100000000000023063.0

but

var d = (decimal)100000000000023063.0

=

100000000000023000

I can get around this problem by storing as a string & have a property that does decimal.Parse() but does anyone know why this is happening?

  • 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-06-06T19:29:18+00:00Added an answer on June 6, 2026 at 7:29 pm

    It’s because 100000000000023063.0 is a double constant, which you’re then converting to decimal, and precision is getting lost.

    Write it like this instead:

    var d = 100000000000023063.0M;
    

    The M suffix tells the C# compiler that the number is a decimal constant.

    In fact you don’t even need the decimal separator for this – i.e. 1M == 1.0M and both are decimals.

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

Sidebar

Related Questions

I have a business class that contains two nullable decimal properties. A third property
Say I have this: class Account ... property :charge, Decimal, :precision => 7, :scale
I have a class that has a decimal property accessible from multiple threads public
In my class I have this property: public decimal Percentage { get; set; }
I have a class with a lot of Decimal properties that are used for
Motive : I have a decimal property in a class which I wish to
I have a class that inherits ActiveRecordValidationBase that contains the following property: [Property] [ValidateDecimal]
Suppose I have simple class Order, that have a TotalPrice calculated property, which can
I have Class and Student objects. Both have collection of another as property. Which
I have class that extend FragmentActivity in it I add fragment to layout as

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.