How to power to negative number? [closed] - java

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'm trying to power something to negative number but it always gives me NaN or Infinity.
How to make eg. 1.25^(-5) ?

The following code:
public class HelloWorld{
public static void main(String []args){
System.out.println(Math.pow(1.25, -5));
}
}
prints:
0.32768
Here is a working code snippet

You can use the Math.pow() method
Math.pow(1.25, -5)

Related

JSON Object java to long [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 months ago.
Improve this question
i have a json object and want to convert it to an int, but i get different numbers. On the first get the output is 1665750692735 (the right One), but on the getInt the output -696618113. Why?
Ok its because its an long. But how i get the long from the JSON Object?
JSON;
{"date":1665750692735,"name":"testDateTwo"}
Method:
public void add(JsonObject date) {
System.out.println((date.get("date")));
System.out.println((date.getInt("date")));
}
because the maximum value of an int is 2147483647,When long converts int, a data overflow occurs

How to print words containing unicode? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to print Swedish words that contain unicode using Java
how can I do it?
for example
Text with Unicode:- \u228sk\u228da
Output: åskåda
Both of the following would work:
class Main {
public static void main(String args[]) {
System.out.println("åskåda");
System.out.println("\u00e5sk\u00e5da");
}
}
Note that you need to use the hex values and must take care of specifying the encoding when reading data (from disk or network)

How to parse XML without Root element using SimpleXML? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
How to parse below result xml(?) using SimpleXML?
<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>
I've solved parsing like this:
#Root(name="boolean")
public class LogonResult {
#Text
boolean _boolean;
}

How do I reverse a number in java [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 13 days ago.
Improve this question
Can anyone explain to me how to reverse a number start with zero in java. I trying to reverse a number 025 but output is only 52. But output should be 520
explanation much appreciated.
You are mixing types. "025" is not a number, it's a String. In a number you simply cannot distinguish between 25, 025, 0025, 00025, ... Implement your assignment as a String operation.
public String reverseString(String s) {
// put your code here
}
You may find very useful the Oracle tutorial on Strings here: https://docs.oracle.com/javase/tutorial/java/data/strings.html

put(java.lang.String,java.lang.Inte ger) in java.util.Map<java.lang.String,java.lang.Integer> cannot be applied to (java.lang.String,java.lang.String) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am getting this error while compiling my code. Please help me with this-
code is
mapConnectionProperties = new HashMap<String, Integer>();
mapConnectionProperties.put(mobileSeriesMappingDTO
.getExternalIP(), mobileSeriesMappingDTO.getExternalPort());
mobileSeriesMappingDTO.getExternalPort() is seemingly a String. Convert it to an Integer.
Integer.parseInt(mobileSeriesMappingDTO.getExternalPort())
Your mobileSeriesMappingDTO.getExternalPort() gives a String,
Transform it to an Integer with :
Integer.parseInt(mobileSeriesMappingDTO.getExternalPort())

Categories

Resources