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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:01:18+00:00 2026-05-17T19:01:18+00:00

i have an application project that both managed and unmanaged code runs and i

  • 0

i have an application project that both managed and unmanaged code runs and i need to use the same algorithm for hashing double values in both systems. so either i will override System.Double.GetHashCode() or use its algorithm in c++ code. i could not find the double.gethashcode algorithm and decided to override the function. but i got a strange error.

Cannot implicitly convert type double
to System.Double

here is the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
  public struct Double
  {
    unsafe public override int GetHashCode()
    {
      fixed (Double* dd = &this)
      {
        int* xx = (int*)dd;
        return xx[0] ^ xx[1] ;
      }

    }
  }
}

namespace ConsoleApplication1
{
  class Program
  {
    static void Main(string[] args)
    {
      double dd = 123.3444; // line 1
      // Double dd = 123.3444; // line 2
      // Cannot implicitly convert type double to System.Double
      Console.WriteLine(dd.GetHashCode());

      Console.ReadLine();
    }
  }
}

if I uncomment line 2 i get Cannot implicitly convert type double to System.Double
error. if i run line 1 then no error occurs but the overriden code never works.

maybe it is very bad thing i am trying. so any one knows about the double.gethashcode algorithm, so i can write equivalent c++ code to get the exact int value?

  • 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-17T19:01:19+00:00Added an answer on May 17, 2026 at 7:01 pm

    This is what I see for Double.GetHashCode():

    //The hashcode for a double is the absolute value of the integer representation
    //of that double.
    // 
    [System.Security.SecuritySafeCritical]  // auto-generated
    public unsafe override int GetHashCode() { 
        double d = m_value; 
        if (d == 0) {
            // Ensure that 0 and -0 have the same hash code 
            return 0;
        }
        long value = *(long*)(&d);
        return unchecked((int)value) ^ ((int)(value >> 32)); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large project that runs on an application server. It does pipelined
I have a Java application that is managed using Maven. The project involves the
I have a fairly old unmanaged C++ program that called managed c# code (vs2003)
I have a web application project that works with a quite large database (over
I have a google web application project that I want to host on github.
I am starting a web application project that will have an Adobe Flex front-end
I have a custom HttpModule rewrite engine in an existing web application project that
I have gwt-project that is comunication to database. Application design mvp pattern and view
I have a Inno Setup project that I want to check if the application
I have an application that contains a VC++ project (along with C# projects). Previously,

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.