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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:25:30+00:00 2026-06-01T19:25:30+00:00

I am porting program from C# to java. I’ve faced a fact that Java

  • 0

I am porting program from C# to java. I’ve faced a fact that

Java

Math.pow(0.392156862745098,1./3.) = 0.7319587495200227

C#

Math.Pow( 0.392156862745098, 1.0 / 3.0) =0.73195874952002271

this last digit leads to sufficient differences in further calculations. Is there any way to emulate c#’s pow?

Thanx

  • 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-01T19:25:32+00:00Added an answer on June 1, 2026 at 7:25 pm

    Just to confirm what Chris Shain wrote, I get the same binary values:

    // Java
    public class Test
    {
        public static void main(String[] args)
        {
            double input = 0.392156862745098;
            double pow = Math.pow(input, 1.0/3.0);            
            System.out.println(Double.doubleToLongBits(pow));
        }
    }
    
    // C#
    using System;
    
    public class Test
    {
        static void Main()
        {
            double input = 0.392156862745098;
            double pow = Math.Pow(input, 1.0/3.0);            
            Console.WriteLine(BitConverter.DoubleToInt64Bits(pow));
        }
    }
    

    Output of both: 4604768117848454313

    In other words, the double values are exactly the same bit pattern, and any differences you’re seeing (assuming you’d get the same results) are due to formatting rather than a difference in value. By the way, the exact value of that double is

    0.73195874952002271118800535987247712910175323486328125
    

    Now it’s worth noting that distinctly weird things can happen in floating point arithmetic, particularly when optimizations allow 80-bit arithmetic in some situations but not others, etc.

    As Henk says, if a difference in the last bit or two causes you problems, then your design is broken.

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

Sidebar

Related Questions

I'm porting a windows program from 32 -> 64 bit. It has a 32
I'm porting a software that build from 16bit color depth to 18bit color depth.
I'm working on a program that records date metadata from files, such as creation
I have a Java program that runs a number of other programs. Once the
I'm porting over a program of mine from python2 to python3, and I'm hitting
I've a C++ project that I'm currently porting from VS2008 to VS2010. When I
I have some code, that I'm currently porting from OS X to Linux (console
I'm using a Java program to POST some XML data from a remote client
We have an application that we're porting to Mac OS from Windows. Once installed,
I'm still new to boost::bind, and now porting a program that was written 2

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.