Skip to content
Advertisement

Tag: decimal

Casting a string to an integer and then to a double – how to retrieve up to four positions behind the decimal position in a correct way?

I am currently working on a simple BMI (Body Mass Index) calculator in Java, in a larger Java / Spring Boot application with Mojito Tests. My function uses height and weight as Input values to calculate the BMI. Through the arithmetic operations, the received Input values – Strings, casted to Integers – result in a number that represents the BMI;

Convert Decimal (Base 10) to Hexadecimal (Base 16) in Java

My question is about Java. How can I convert Decimal (Base 10) to Hexadecimal (Base 16) in Java with Java 7? When I use in C# the method Convert.FromBase64String(str) with String “BQoPFBke” i get the result: 05-0A-0F-14-19-1E But when I use in Java the method Base64.Decoder.decode(str) with the same String I get the result: [5, 10, 15, 20, 25, 30]

change binary to decimal

I have to write a method that changes binary to decimal. Write a method that will convert the supplied binary digit (as a string) to a decimal number. convertToDecimal(“01101011”) = 107 convertToDecimal(“00001011”) = 11 i have created it to change decimal to binary however im not sure how to create it binary to decimal. Answer

Convert Decimal to Hex using Recursive method Java

I need to make a recursive method that converts a decimal into hexadecimal. I can’t use Integer.toHexString. EDIT:I tried this code but it doesn’t work properly Edit: Changed the default case and the if (n == 0) loop return statement and it works beautifully now. new code: Answer The problem is in your default clause: it should read: That will

Converting Decimal to Binary Java

I am trying to convert decimal to binary numbers from the user’s input using Java. I’m getting errors. How do I convert Decimal to Binary in Java? Answer Your binaryForm method is getting caught in an infinite recursion, you need to return if number <= 1:

Advertisement