exponentiation Questions
2
Solved
So I was fooling around with the new exponentiation operator and I discovered you cannot put a unary operator immediately before the base number.
let result = -2 ** 2; // syntax error
let result = ...
Goldschmidt asked 2/11, 2017 at 6:20
20
What function does the ^ (caret) operator serve in Java?
When I try this:
int a = 5^n;
...it gives me:
for n = 5, returns 0
for n = 4, returns 1
for n = 6, returns 3
...so I guess it do...
Dammar asked 2/1, 2010 at 11:44
3
Solved
I have the following power function which operates on integers and it works fine:
int ipow( int base, int exp )
{
int result = 1;
while( exp )
{
if ( exp & 1 )
{
result *= base;
}
exp ...
Scalene asked 5/3, 2013 at 13:22
6
Solved
I was trying to raise an integer to a power using the caret operator (^), but I am getting surprising results, e.g.:
assert_eq!(2^10, 8);
How can I perform exponentiation in Rust?
Gemination asked 6/7, 2018 at 10:46
11
Solved
The built-in Math.Pow() function in .NET raises a double base to a double exponent and returns a double result.
What's the best way to do the same with integers?
Added: It seems that one can just...
Protein asked 20/12, 2008 at 18:40
4
Solved
I am reading an Intro to Python textbook and came across this line:
Operators on the same row have equal precedence and are applied left to right, except for exponentiation, which is applied rig...
Locative asked 22/11, 2017 at 8:0
4
Solved
I need a way to calculate:
(g^u * y^v) mod p
in Java.
I've found this algorithm for calculating (g^u) mod p:
int modulo(int a,int b,int c) {
long x=1
long y=a;
while(b > 0){
if(b%2 == 1...
Immoderate asked 1/11, 2010 at 6:10
5
Solved
My problem is to compute (g^x) mod p quickly in JavaScript, where ^ is exponentiation, mod is the modulo operation. All inputs are nonnegative integers, x has about 256 bits, and p is a prime numbe...
Jolie asked 20/9, 2009 at 8:48
15
Solved
How can I do exponentiation in clojure?
For now I'm only needing integer exponentiation, but the question goes for fractions too.
Polston asked 20/2, 2011 at 12:32
20
Solved
What is the most efficient way given to raise an integer to the power of another integer in C?
// 2^3
pow(2,3) == 8
// 5^5
pow(5,5) == 3125
Copalite asked 19/9, 2008 at 12:30
10
Solved
I don't see an exponentiation operator defined in the base arithmetic operators in the Swift language reference.
Is there really no predefined integer or float exponentiation operator in the lang...
Salicin asked 5/6, 2014 at 16:46
3
Solved
What is the benefit to using the ECMAScript 2016 exponentiation operator over the current Math.pow()? In other words, besides reducing key strokes, what is the difference between
Math.pow(2, ...
Marra asked 2/6, 2016 at 20:8
4
I am taking a class in C++ and I noticed there are only a few math operators to use.
I also noticed that C++ does not come with an exponential operator within its math library.
Why must one alwa...
Catalan asked 23/9, 2010 at 3:24
0
I found a fast binary logarithm algorithm for fixed points in an answer to this question: Fast fixed point pow, log, exp and sqrt, based on an algorithm by Clay S. Turner. Is it possible to "revers...
Grievance asked 28/4, 2020 at 2:4
4
Solved
What is the Prolog operator ^ ?
Looking at The Prolog Built-in Directive op gives a list of the built-in operators.
I see
** is exponentiation
/\ is or
but what is ^ ?
Each of the three cur...
Ioyal asked 12/11, 2013 at 14:26
17
Solved
How do I raise a number to a power?
2^1
2^2
2^3
etc...
Cortney asked 10/5, 2009 at 19:18
3
Solved
MATLAB's power function to calculate element-wise exponential for a constant base and an array of exponents becomes noticeably faster when the size of the array becomes 512. I expected to see the c...
Caputo asked 10/7, 2019 at 14:0
3
Solved
what is the fastest method to calculate this, i saw some people using matrices and when i searched on the internet, they talked about eigen values and eigen vectors (no idea about this stuff)...the...
Handedness asked 24/5, 2014 at 15:23
3
Solved
I know it has been proven NP-complete, and that's ok. I'm currently solving it with branch and bound where I set the initial upper limit at the number of multiplications it would take the normal bi...
Estrogen asked 7/9, 2011 at 8:15
2
I am realizing Exponentiation of a matrix using FOR:
import numpy as np
fl=2
cl=2
fl2=fl
cl2=cl
M = random.random((fl,cl))
M2 = M
Result = np.zeros((fl,cl))
Temp = np.zeros((fl,cl))
itera = 2
prin...
Sallust asked 25/9, 2018 at 19:48
1
Solved
Please consider std::exp defined in the header cmath in C++ numerics library. Now, please consider an implementation of the C++ Standard Library, say libstdc++.
Considering there are various algor...
Hoad asked 21/4, 2018 at 20:36
5
Solved
I've been trying to calculating 2^100 in Golang. I understand the limit of numeric type and tried using math/big package. Here's what I've tried but I can't figure out why it doesn't work.
I've u...
Epiphytotic asked 12/5, 2015 at 5:0
1
Solved
Having perused the MSDN documentation for both the ^ (hat) operator and the Math.Pow() function, I see no explicit difference. Is there one?
There obviously is the difference that one is a functio...
Infusive asked 5/5, 2017 at 12:23
2
Solved
Executing it in the browser console it says SyntaxError: Unexpected token **.
Trying it in node:
> -1**2
...
...
...
...^C
I thought this is an arithmetic expression where ** is the power ope...
Lifeblood asked 22/4, 2017 at 7:54
2
Solved
How do I raise a scipy.sparse matrix to a power, element-wise? numpy.power should, according to its manual, do this, but it fails on sparse matrices:
>>> X
<1353x32100 sparse matrix of...
Heraclid asked 21/6, 2011 at 20:27
1 Next >
© 2022 - 2024 — McMap. All rights reserved.