473,395 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do I raise a value to a negative number?

Paul Johnson
Hi,

I'm using Math.Pow to raise a number to another number (I know, that b * b is quicker than using Math.Pow, but this is different).

The problem is that the number I need to raise to is a negative real i.e.

-1.285 ^ -0.625

Currently, this gives me NaN which is pretty useless.

Is there a way around this that will allow me to raise to a negative real?

Thanks
Aug 25 '11 #1

✓ answered by snehasismishra1

Hi Paul,

-1.285 ^ -0.625 = (1/-1.285)0.625 = -[(1/1.285)0.625]

and the value is negative or positive is depends on the value of power. If even then positive, else negative. So u can do as below.

double a = -1.285;
double _a = Math.Abs(a);
double b = -0.625;
double _b = Math.Abs(b);
double c = Math.Pow(_a, _b);
double d = -(1 / c);

Thanks,
Snehasis

1 3867
Hi Paul,

-1.285 ^ -0.625 = (1/-1.285)0.625 = -[(1/1.285)0.625]

and the value is negative or positive is depends on the value of power. If even then positive, else negative. So u can do as below.

double a = -1.285;
double _a = Math.Abs(a);
double b = -0.625;
double _b = Math.Abs(b);
double c = Math.Pow(_a, _b);
double d = -(1 / c);

Thanks,
Snehasis
Aug 25 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Jason | last post by:
Hi, below is example code which demonstrates a problem I have encountered. When passing a number to a function I compare it with a string's size and then take certain actions, unfortunately during...
16
by: JKop | last post by:
Take a class like the following: class Finger { public: double length; }
7
by: hasanainf | last post by:
Hi all, I have two querys QueryPurchased ProductID Location TotPcs Prod1 Loc1 100 Prod2 Loc1 50 Prod3 Loc1 150 Prod3 Loc3 150
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
1
by: Wayne | last post by:
There is probably a simple solution to this but: I have a textbox that is bound to a number field in a table. The field type is "double". If I enter a negative value directly into the table it...
3
by: Frederick Gotham | last post by:
(I'm not sure if there's already something in the Standard Library for doing this... ?) Is the following macro okay for getting a compile-time constant that indicates which negative number...
20
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including...
5
by: wilboy | last post by:
Hi everyone I have a small problem here. I only want return positive number or zero when - . Eg. - = 48.50 - 52.60 = 0 78.20 ...
3
by: Peng Yu | last post by:
Hi, I don't understand why rbegin() -rend() gives a negative number. Since rbegin() + 1 gives the one before the last element, I think rbegin() - rend() should give a positive number. ...
1
by: santoshsri | last post by:
Hi All, My C# web application calls a webservice to process a report. It sends XMLs as parameter and in response gets an XML node which stores Binay datatype bin.base64. It makes an instance of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.