Linked Questions
45 questions linked to/from What does the ^ operator do in Java?
0 votes
1 answer
48 views
byte[] array in Java(size declaration) [duplicate]
I have declared 3 different types of byte arrays(of different sizes). See the comment next to each as I am not able to understand how the length is computed by the compiler? byte[] byteField0 = ...
0 votes
0 answers
33 views
How do I represent potency in Java with all zeros? [duplicate]
I have a task from school in which I have to display numbers with potencies with the help of system out print. The problem is that all zeroes have to be displayed and that's not working for me. Here'...
-3 votes
1 answer
54 views
Trouble using the ^ operator in a calculator in netbeans (Java) [duplicate]
The error i get is "bad operand types for binary operator ^ first type: float second type: float" this error happens in case 5 of the switch x y and r are floats and n is an Int switch (n) ...
0 votes
0 answers
27 views
What does "^" do in eclipse? [duplicate]
I was using eclipse recently, trying to make a scientific calculator that performs specific functions when I tried exploring how to put a number to a specific power. As I was exploring how to perform ...
45 votes
22 answers
304k views
How to concatenate int values in java?
I have the following values: int a=1; int b=0; int c=2; int d=2; int e=1; How do i concatenate these values so that i end up with a String that is 10221; please note that multiplying a by 10000, b ...
62 votes
11 answers
256k views
Why is my power operator (^) not working?
#include <stdio.h> void main(void) { int a; int result; int sum = 0; printf("Enter a number: "); scanf("%d", &a); for( int i = 1; i <= 4; i++ ) { ...
59 votes
5 answers
36k views
How to find the only number in an array that doesn't occur twice [duplicate]
The following is taken from a job interview: In a given array, which contains integers, each number repeats itself once except for one, which doesn't repeat. Write a function that finds the ...
31 votes
4 answers
42k views
Why doesn't C++ have a power operator? [closed]
Many languages have a power operator; why doesn't C++? For example, Fortran and Python use ** and is commonly written (in LaTeX, for example) using ^.
7 votes
4 answers
12k views
Java Operator Precedence Comparison
Does java have a built-in method to compare precedence of two operators? For example, if I have a char '/' and a char '+' is there a method I can call that compares the two and returns true/false if ...
3 votes
5 answers
6k views
Storing int value of bitmask - extract 1 valued bits
I am calculating the int equivalent of a given set of bits and storing that in memory. From there, I would like to determine all 1 value bits from the original bitmask. Example: 33 --> [1,6] 97 --> [...
3 votes
6 answers
3k views
How to implement (x pow y) in java,where x,y are double?
I want to calculate x power y and both x,y are double values. Why is java giving me a compilation error? What is the best way to do so? I am currently using the following method: x^y // attempt to ...
1 vote
1 answer
9k views
Exponent Math in Java [duplicate]
Could anyone explain to me why System.out.println(100*(1-10^(-10/10))); results in the number "800" being printed out? The correct answer is 90 when you use a calculator. How would I go about doing ...
2 votes
8 answers
3k views
How would someone implement mathematical formulae in Java? [closed]
How would someone implement mathematical formulae in Java? What I mean, the user inputs a string with multiple variables. Like a simple quadratic formula: x^2 + 5x + 10. Or in Java: (Math.pow(x,2)) + ...
3 votes
3 answers
721 views
string to integer
I have made a program which converts numbers entered into a string into an integer like atoi does, but its giving wrong output. #include<stdio.h> #include<conio.h> #include<math.h> #...
4 votes
3 answers
244 views
Difference between 2^0*2 and (2^0)*2?
I have expected both expression's will give same answer: System.out.println(2^0*2); System.out.println((2^0)*2); Output: 2 4 Is there a specific reason why 2^0*2 = 2 and (2^0)*2 = 4?