Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 4 months ago. Improve this question

# Tag: double

## Java Calculator program issue

I am trying to develop a calculator program that inputs an arithmetic expression of the form number operator number = and computes the result of the expression. The expression will be evaluated from left to right not considering regular operator precedence. For example, the expression 14 – 5 * 3 = will produce 27.0. The value = displays the final

## (Java) How do you check a string for two or more digit integers using .matches()?

The objective of this program is to return the atomic mass from a given formula (as a String), using a CSV file that contains elements and their atomic masses. My code for this particular problem is this: I have another method “fileReader” that takes the data from the mile and returns a map with the elements as the key and

## Filter distinct groups and get average of String values parsing as Integer or Double

I have a POJO like below: And a List like below: Now I am trying to filter and group all the employees by department and need to get the highest spending department. If salary is of type Double (say) I can do it like below: And I get the expected output: But I am clueless what to do if I

## How to convert from a double without a fractional part to a hexaicosadecimal string (base-26)?

I am wondering how do you convert from a double without a fractional part to a hexaicosadecimal string? What are some methods for converting and are there short cuts? Answer As far as I understood it is a base 26 conversion to letters only, with a prefix “c”. Not sure on the sign for a negative- number. One “shortcut” would

## Trying to create a calculator for Newton’s Square Root without using built-in things for school. I have it down but the math is a little off

I will be able to accept an answer in 6 minutes. For now going to state that my answer has successfully been solved by Elliott Frisch. He provided a solution to fix the problem I ran into. When attempting to do the “Equation” it correctly performs the action but seems to be off. Off being that it doesn’t really display

## Comparison of Double Constants

I researched this a lot and I know something about precision errors in the doubles; however I couldnt find the answer. My question is: is it always safe to compare double constants? What do I mean by that is, just reading the double from a string or creating in the source code. No operation (adding, subtracting etc.) will be done

## How can I intentionally create random floating point / decimal precision errors in java?

My goal is to generate random numbers that all have decimal precision errors. Here are some examples of types of numbers I would like to generate: Here are strategies I have tried. parseFloat(“4.01500000000000000001”); BigDecimal.valueOf(ThreadLocalRandom.current().nextFloat()).multiply(BigDecimal.valueOf(ThreadLocalRandom.current().nextFloat())).doubleValue(); None of the things I tried have created even a single number similar to that which I am looking for. Answer Assuming that the exact values

## ‘OptionalDouble.getAsDouble()’ without ‘isPresent()’ check

I’ve seen a bunch of solutions for this question but no matter what I try, IDEA still reports an error. Consider the following block: This reports a warning of ‘OptionalDouble.getAsDouble()’ without ‘isPresent()’ check. If I try this then it doesn’t compile: Neither does this: Or this: While i know these optional doubles will never be null, i’d like to resolve

## Game Of Life game: Check 2D array 8 closest surroundings; ArrayIndexOutOfBoundsException issue

I have encountered this problem and i couldn’t find the solution. There is a 2D array with only zeros and ones in it (the size of the array doesnt really matter, i worked with 10×10). Zero means dead and 1 is alive. I double for looped this to check the elements sorroundings and when it sorrounded with other “cells” the