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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:54:15+00:00 2026-06-17T01:54:15+00:00

When performing exponential calculations using a negative number as the base, inconsistent results are

  • 0

When performing exponential calculations using a negative number as the base, inconsistent results are returned when using the raw value as opposed to a variable containing the value.

In IRB:

1.9.3p194 :001 > -4.5 ** 0.5
 => -2.1213203435596424 
1.9.3p194 :002 > foo = -4.5
 => -4.5 
1.9.3p194 :003 > foo ** 0.5
 => (1.2989340843532398e-16+2.1213203435596424i) 
1.9.3p194 :004 > (-4.5) ** 0.5
 => (1.2989340843532398e-16+2.1213203435596424i) 

What gives? Obviously the compiler is interpreting -4.5 ** 0.5 as -(4.5 ** 0.5), but why the different behavior when using a variable?

  • 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-17T01:54:16+00:00Added an answer on June 17, 2026 at 1:54 am

    It’s taking the first line as

    -(4.5 ** 0.5)
    

    which gives the negative square root of 4.5.
    The second equation is equivalent to

    (-4.5) ** 0.5
    

    hence the complex answer.

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

Sidebar

Related Questions

I have blocks performing calculations using a function step() . The blocks can be
Occasionally when performing a rebase using the MercurialEclipse plugin my repository gets thrown into
I'm performing a simulation of a simple queue using SimPy . One of the
When performing a schema compare having db_owner rights on the target database results in
When performing UPDATE and INSERT queries using Zend_Db, I frequently need to set values
When performing a search of shops and paginating the results (10 per page) on
When performing a factor analysis using factanal the usual result is some loadings table
After performing the Schur factorization using function Schur in library 'Matrix', how do I
When performing bitwise subtraction using two's complement, how does one know when the overflow
When performing an insert lets say from C# into a SQL Server table (using

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.