Questions tagged [exponent]

Exponentiation is a mathematical operation, written as b raised to the power of n, involving two numbers, the base b and the exponent (or power) n.

Exponentiation refers to the mathematical operation involving two numbers, one is a base and another is an exponent. It is repeated multiplication. To calculate 53 you have to multiply the number 5 (base) by itself 3 times (exponent).

588 questions
248
votes
9 answers

Is there an exponent operator in C#?

For example, does an operator exist to handle this? float Result, Number1, Number2; Number1 = 2; Number2 = 2; Result = Number1 (operator) Number2; In the past the ^ operator has served as an exponential operator in other languages, but in C# it…
Charlie
  • 2,491
  • 2
  • 14
  • 4
114
votes
10 answers

Parse a Number from Exponential Notation

I need to parse the string "1.2345E-02" (a number expressed in exponential notation) to a decimal data type, but Decimal.Parse("1.2345E-02") simply throws an error
Jimbo
  • 22,379
  • 42
  • 117
  • 159
104
votes
4 answers

Exponentiation in Haskell

Can someone tell me why the Haskell Prelude defines two separate functions for exponentiation (i.e. ^ and **)? I thought the type system was supposed to eliminate this kind of duplication. Prelude> 2^2 4 Prelude> 4**0.5 2.0
skytreebird
  • 1,041
  • 2
  • 8
  • 3
81
votes
6 answers

Does Java have an exponential operator?

Is there an exponential operator in Java? For example, if a user is prompted to enter two numbers and they enter 3 and 2, the correct answer would be 9. import java.util.Scanner; public class Exponentiation { public static double powerOf…
user3362992
  • 843
  • 1
  • 6
  • 4
70
votes
3 answers

JSON standard - floating point numbers

I am wondering whether the following floating point notation is a valid JSON notation: "result":{"base_fee":1e-005} or should the exponent notation be replaced with a decimal notation?
ThePiachu
  • 8,695
  • 17
  • 65
  • 94
61
votes
10 answers

Optimizations for pow() with const non-integer exponent?

I have hot spots in my code where I'm doing pow() taking up around 10-20% of my execution time. My input to pow(x,y) is very specific, so I'm wondering if there's a way to roll two pow() approximations (one for each exponent) with higher…
Cory Nelson
  • 29,236
  • 5
  • 72
  • 110
46
votes
4 answers

UNIX sort with exponential values?

I have a csv file with 7 fields of data. I want to sort the 7th field in reverse numerial order (smallest values first). The 7th field of data looks like this: 0.498469643137 1 6.98112003175e-10 9.11278069581e-06 I have tried to use the UNIX sort…
drbunsen
  • 10,139
  • 21
  • 66
  • 94
43
votes
3 answers

Python and Powers Math

I've been learning Python but I'm a little confused. Online instructors tell me to use the operator ** as opposed to ^ when I'm trying to raise to a certain number. Example: print 8^3 Gives an output of 11. But what I'm look for (I'm told) is more…
Interrupt
  • 965
  • 3
  • 9
  • 16
36
votes
1 answer

Why does python add an 'L' on the end of the result of large exponents?

If you've noticed, python adds an L on to the end of large exponent results like this: >>> 25 ** 25 88817841970012523233890533447265625L After doing some tests, I found that any number below 10 doesn't include the L. For example: >>> 9 **…
NotAGoodCoder
  • 417
  • 2
  • 6
  • 9
25
votes
4 answers

Number of digits in exponent

Is it possible to set the number of digits to be used for printing the exponent of a floating-point number? I want to set it to 3. Currently, f = 0.0000870927939438012 >>> "%.14e"%f '8.70927939438012e-05' >>> "%0.14e"%f '8.709279e-005' What I want…
nmadzharov
  • 482
  • 2
  • 6
  • 12
25
votes
3 answers

Why do we bias the exponent of a floating-point number?

I'm trying to wrap my head around this floating point representation of binary numbers, but I couldn't find, no matter where I looked, a good answer to the question. Why is the exponent biased? What's wrong with the good old reliable two's…
so.very.tired
  • 2,958
  • 4
  • 41
  • 69
25
votes
3 answers

OEIS A002845: Number of distinct values taken by 2^2^...^2 (with n 2's and parentheses inserted in all possible ways)

I am looking for a reasonably fast algorithm to calculate terms of the OEIS sequence A002845. Let me restate its definition here. Let ^ denote the exponentiation operator. Consider expressions of the form 2^2^...^2 having n 2's with parentheses…
Vladimir Reshetnikov
  • 11,750
  • 4
  • 30
  • 51
24
votes
2 answers

Using fractional exponent with bc

bc, a Linux command-line calculator, is proficient enough to calculate 3^2 9 Even a negative exponent doesn't confuse it: 3^-2 0.11111 Yet it fails when it encounters 9^0.5 Runtime warning (func=(main), adr=8): non-zero scale in exponent How…
Antony Hatchkins
  • 31,947
  • 10
  • 111
  • 111
20
votes
3 answers

Rounding to a power of 10

I have a variable, tauMax, that I want to round up to the nearest power of ten(1, 10, 100, 1000...). I am using the below expression to find the closest integer to the max value in the tau array. I am finding the max value because I am trying to…
Alex Nichols
  • 876
  • 5
  • 12
  • 23
20
votes
3 answers

SAS function for using 'power' / exponential

I may be missing something obvious, but how do you calculate 'powers' in SAS? Eg X squared, or Y cubed? what I need is to have variable1 ^ variable2, but cannot find the syntax... (I am using SAS 9.1.3)
Allan Bowe
  • 12,306
  • 19
  • 75
  • 124
1
2 3
39 40