double

Groovy/Grails autoconvert NaN string to double field

笑着哭i 提交于 2020-01-06 03:25:06
问题 I want to let users edit a field with double data in Grails view. I want to allow Double.NaN (to void values). There is a special char looking like a diamond with a question mark in it (in HTML) that acts like NaN, but - well - the users wont find that on their keys. In Java it works with Double.valueOf("NaN") . But typing NaN in the input field will throw a IllegalArgumentException saying "NaN" is an Unparseable Number. What method is callled for conversion? Whats the key to let it

How do I format a double value in XAML to German format on a DataGridTextColumn?

本秂侑毒 提交于 2020-01-06 02:18:45
问题 I have this simple piece of code and I am wondering how to convert it to German format (#.###,##) ? // displays #.## <DataGridTextColumn Header="Sum Value" Binding="{Binding SumValue}"/> 回答1: In this case try several options: A. Global setting language culture for the entire application, it can solve some problems related to the current language culture. Add Startup event for App.xaml , which establishes the necessary language culture. It affects the display of the date, double values​​, sums

Convert double to String in Java [duplicate]

大城市里の小女人 提交于 2020-01-05 12:30:40
问题 This question already has answers here : Double decimal formatting in Java (14 answers) Closed 5 years ago . I am to convert a double value to a String. double d=12345678.999; String str = String.valueOf(d); or, just plain String str = ""+d; Does it, however in the exponent form-- returning the String value: 1.2345678999E7 I need the value as is in the String: 12345678.999 Is there a way to do this? I can parse the string for the value of exponent-- the portion after 'E' and go from there,

Float value is not correct when parsing it from a String, double works, why?

橙三吉。 提交于 2020-01-05 11:20:09
问题 I input 179.9 in an EditText . When I retrieve it, the value is different if it's stored as a float . final EditText valueInput = mEntryDialogView.getValueInput(); final CharSequence input = valueInput.getText(); final String inputAsString = input.toString().trim(); final float asFloat = Float.valueOf(inputAsString); //179.899994 final double asDouble = Double.valueOf(inputAsString); //179.9 Something fishy is going on here, could anyone explain to me why the float value is not correct ? Even

floor double by decimal place

前提是你 提交于 2020-01-04 09:25:14
问题 i want to floor a double by its decimal place with variable decimal length (in iphone sdk). here some examples to show you what i mean NSLog(@"%f",[self floorMyNumber:34.52462 toPlace:2); // should return 34.52 NSLog(@"%f",[self floorMyNumber:34.52662 toPlace:2); // should return 34.52 NSLog(@"%f",[self floorMyNumber:34.52432 toPlace:3); // should return 34.524 NSLog(@"%f",[self floorMyNumber:34.52462 toPlace:3); // should return 34.524 NSLog(@"%f",[self floorMyNumber:34.12462 toPlace:0); //

floor double by decimal place

蓝咒 提交于 2020-01-04 09:24:16
问题 i want to floor a double by its decimal place with variable decimal length (in iphone sdk). here some examples to show you what i mean NSLog(@"%f",[self floorMyNumber:34.52462 toPlace:2); // should return 34.52 NSLog(@"%f",[self floorMyNumber:34.52662 toPlace:2); // should return 34.52 NSLog(@"%f",[self floorMyNumber:34.52432 toPlace:3); // should return 34.524 NSLog(@"%f",[self floorMyNumber:34.52462 toPlace:3); // should return 34.524 NSLog(@"%f",[self floorMyNumber:34.12462 toPlace:0); //

printf parameters affecting each other

假如想象 提交于 2020-01-04 06:51:09
问题 I have the following code: double dtemp = (some value) printf("\n***Hand washing: cost per kg/item: %.2f, cost: %.2f.\n", 5, dtemp); It prints out: ***Hand washing: cost per kg/item: 0.00, cost: 0.00. And when I change the constant 5 into a double variable holding 5, it prints (according to the input): ***Hand washing: cost per kg/item: 5.00, cost: 20.00. Why would the constant 5 affect the evaluation of the dtemp? I'm using gcc 4.6.2 (MinGW) and tested it also in TCC. 回答1: My compiler's (gcc

doubleValue does not convert the object to a double value correctly at all times

爷,独闯天下 提交于 2020-01-04 06:35:21
问题 I have an NSArray in which I would like to store double values. I defined it as follow NSMutableArray *setOfDoubles; I add the elements as follow NSNumber *num; num = [NSNumber numberWithDouble:someDouble]; [setOfDoubles addObject:num]; And I read the element as follow num = [setOfDoubles lastObject]; [setOfDoubles removeLastObject]; doubleValueToUse = [num doubleValue]; My problem is sometimes (Not always), for example when num (as an object) is 5.1, doubleValueToUse (as a double value) is 5

Double to Byte type conversion error

寵の児 提交于 2020-01-04 06:05:37
问题 When performing conversion from byte to double by mathematical operations I've got expected result. Performing the same mathematical operations to reverse the changes in value, results in correct value as long as I keep double type. But when at the end I converts double result back to byte value the conversion results is incorrect by 1. This is the case only for some byte values. Exact process: byte b = 82; Console.WriteLine(b); // initial byte value double d = (b / 100.0) + 2.00; Console

Double to Byte type conversion error

纵然是瞬间 提交于 2020-01-04 06:05:19
问题 When performing conversion from byte to double by mathematical operations I've got expected result. Performing the same mathematical operations to reverse the changes in value, results in correct value as long as I keep double type. But when at the end I converts double result back to byte value the conversion results is incorrect by 1. This is the case only for some byte values. Exact process: byte b = 82; Console.WriteLine(b); // initial byte value double d = (b / 100.0) + 2.00; Console