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

  • Home
  • SEARCH
  • 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 6319707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:51:05+00:00 2026-05-24T15:51:05+00:00

Possible Duplicate: How to determine if a decimal/double is an integer? I have a

  • 0

Possible Duplicate:
How to determine if a decimal/double is an integer?

I have a unique situation in which all numbers must be saved as double data type in my database, but only in certain conditions is the precision beyond the integer level valuable.

At first, I tried to just use int and then abstract to a new table when these unique fractional occurances would happen, but after doing that for weeks I can see now that it is excessively stupid and wasting my time.

I know that I can turn a double into an int. That is easy. I know how to translate it over. What I do not know is how to TEST for translating it over. I basically wish to come up with a short, easy way to say

Is this number really a double, or is it just an int?

If it is an int (and most of the time, it will be), then I will turn it into one and treat it as such. But due to the uniqueness of the requirements, I have to still save everything in the database as double.

Any ideas? I know this is a newbie question, and I’ve googled around for several hours and am still left quite confused.

  • 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-24T15:51:06+00:00Added an answer on May 24, 2026 at 3:51 pm

    This similar post shows you how to determine if a double or decimal has decimal places or not. You can use this to determine what type it is and then store appropriately.

    Accepted answer from that post:

    For floating point numbers, n % 1 == 0 is typically the way to check if there is anything past the decimal point.

    public static void Main (string[] args)
    {
        decimal d = 3.1M;
        Console.WriteLine((d % 1) == 0);
        d = 3.0M;
        Console.WriteLine((d % 1) == 0);
    }
    

    Output:

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

Sidebar

Related Questions

Possible Duplicate: How to determine if a decimal/double is an integer? I have a
Possible Duplicate: Determine framework (CLR) version of assembly I have a library/DLL file which
Possible Duplicate: Fastest way to determine if an integer's square root is an integer
Possible Duplicate: How can I determine a web user's time zone? Which is the
Possible Duplicate: How to determine the class of a generic type? I have a
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Determine device (iPhone, iPod Touch) with iOS I am making a game
Possible Duplicate: How to determine the date one day prior to a given date

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.