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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:58:49+00:00 2026-06-12T17:58:49+00:00

I was astounded to find that the System.Numerics.Complex data type in .NET doesn’t yield

  • 0

I was astounded to find that the System.Numerics.Complex data type in .NET doesn’t yield mathematically accurate results.

Complex.Sqrt(-1) != Complex.ImaginaryOne

Instead of (0, 1), I get (6.12303176911189E-17, 1), which looks a lot like a rounding error.

Now I realize that floating point arithmetic will lead to results like this sometimes, but usually using integers will avoid rounding errors.

Why does this seemingly basic operation yield an obviously wrong result?

  • 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-12T17:58:51+00:00Added an answer on June 12, 2026 at 5:58 pm

    Look at the decompiled Sqrt method.

    public static Complex Sqrt(Complex value)
    {
        return Complex.FromPolarCoordinates(Math.Sqrt(value.Magnitude), value.Phase / 2.0);
    }
    

    There is in fact a rounding error caused by using polar coordinates and radians. value.Phase / 2.0 will return pi/2, which isn’t an exactly representable number. When converting from polar coordinates (1, pi/2), the rounding error becomes visible when the real coordinate nears zero.

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

Sidebar

Related Questions

Context: I am astounded by the number of front end developers that hack at
Astounded this question didn't show up in the related questions list. There's some similar
I basically started today with WPF, and I'm astounded by how difficult it is
I'll be the first to admit that my overall knowledge of low level programming
I've just discovered that using <div /> instead of <div></div> completely destroys my page
Given this simple code snippet I am astounded to provoke a stack overflow this
This is cross-posted on the ggplot2 google group My situation is that I'm working
I am working on an embedded system running Linux on a DSP. Now we
I'm quite astounded by the apparent complexity of this seemingly simple task. I know
I'm using play-framework 2.0 (java web-framework) with postgresql. what encryption type for a user's

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.