LordBeerus
LordBeerus
JCHJava Community | Help. Code. Learn.
Created by LordBeerus on 11/7/2024 in #java-help
problem here
this method aint working how its supposed to. It works for most cases, but not all for some reason. also not for -+ and -- max value what ever that shoudl mean. The following test cases are failing (also i cant use if statements, dont ask why :/): Test Case · decryptFloat - RandomPositives failed Some positive values seem to produce wrong number triplets Test Case · decryptFloat - RandomNegatives failed Some positive values seem to produce wrong number triplets Test Case · decryptFloat - +MAX_VALUE failed Did you consider all values? Test Case · decryptFloat - -MAX_VALUE failed Did you consider all values? public String decryptFloat(float fx) { //float adjustedFx = (fx == Float.MAX_VALUE fx == Float.MIN_VALUE) ? Float.NaN : fx; float value = (fx + mbox.getIntHint()) * mbox.getFloatHint(); //float adjValue = (value == Float.MAX_VALUE value == Float.MIN_VALUE) ? Float.NaN : value; double value1 = Math.abs(Math.cos(value)); value1 = Math.max(-1.0, Math.min(1.0, value1)); String value3 = String.format("%.3f", value1); String value4 = value3.replaceFirst("^0\.0*", ""); String value5 = value4.substring(value4.indexOf(".")+1); return value5; }
22 replies