Can printf() produce "-.5" for the value (-0.5)?
i.e. can printf be told to ignore zero when it precedes the decimal point? ...
i.e. can printf be told to ignore zero when it precedes the decimal point? ...
I have this static method, it receives a double and "cuts" its fractional tail leaving two digits after the dot. works almost all the time. I have noticed that when it receives 2.3 it turns it to 2.29. This does not happen for 0.3, 1.3, 3.3, 4.3 and 102.3. Code basically multiplies the number by 100 uses modf divides the integer value by...
Hi, the below Default.aspx page(code behind is given below) contains a composite control. If we assign an Id to this composite control,while page rendering it creates multiple "ID" attribute for its child controls like "". Removing obj.ID = "MyCompositeControl" creates a single id for all child controls, but we can't set our own name. Co...
System.out.println(2.14656); 2.14656 System.out.println(2.14656%2); 0.14656000000000002 WTF? ...
Is something broken or I fail to understand what is happening? static String getRealBinary(double val) { long tmp = Double.doubleToLongBits(val); StringBuilder sb = new StringBuilder(); for (long n = 64; --n > 0; tmp >>= 1) if ((tmp & 1) == 0) sb.insert(0, ('0')); else sb.insert(0, (...
I've found a problem with the strtod method which I've used all this time. First of all it doesn't understand non-point decimal separator, so I've forced to use this: std::replace(sSource.begin(), sSource.end(), getDecimalSeparator(), '.'); But no I've found another problem and didn't found how to resolve it yet. If the value is negat...
I know that most programming languages have functions built in for doing that for you, but how do those functions work? ...
I have an pojo like this: public class LocationPoint { protected double la; protected double lo; public double getLat() { return la; } public void setLat(double value) { this.la = value; } public double getLong() { return lo; } public void setLong(double value) { t...
Hi, I want to use the for loop for my problem, not while. Is it possible to do the following?: for(double i = 0; i < 10.0; i+0.25) I want to add double values. ...
Hey guys, I am trying to format a double to 2 decimal places with leading zeros and there's no luck. Here is my code: Double price = 32.0; DecimalFormat decim = new DecimalFormat("#.##"); Double price2 = Double.parseDouble(decim.format(price)); And I want output to be 32.00 instead I get 32.0 Any solutions?? ...
Possible Duplicates: Difference between float and double strange output in comparision of float with float literal I am using visual C++ 6.0 and in a program I am comparing float and double variables For example for this program #include<stdio.h> int main() { float a = 0.7f; double b = 0.7; printf("%d %d...
Hi all! How to disable symbols after dot in double values? 13 + 3.456 = 16.456 GOOD 13 + 1 = 14.00 BAD! I need 14 how can I do It? I am using NSMutableString. ...
hello i have an application project that both managed and unmanaged code runs and i need to use the same algorithm for hashing double values in both systems. so either i will override System.Double.GetHashCode() or use its algorithm in c++ code. i could not find the double.gethashcode algorithm and decided to override the function. but ...
Hello There! I have a method that receives a number in a NSString format. I wish to convert this string to a double which I can use to calculate a temperature. Here's my method. NSString *stringTemp = text; // text is a NSString NSLog(@"%@",stringTemp); // used for debugging double tempDouble = [stringTemp doubleValue]; NSLog(@"%f",...
Hi people. I would need a regular expression that escapes or captures (if not already escaped) ALL the double quote characters INSIDE a single quoted string and then convert the opening single quotes to double quotes! We are refactoring files that have a lot (and i mean a lot!) of single quoted strings in either PHP and also JS files. ...
double SampleInterval = (PopulationValue - valueOfSignItems) / (SampleSize - noOfSignItems); if my divisor = 0, sampleInterval wil bcom infinity and it will be = NaN if both dividend and divisor are = 0 i need to do my code when SampleInterval = infinity and in another context when SampleInterval = NaN. How it is possible..?? can any ...
37.807614 to 37.786996 The randomly generated double must have the same precision (num of digits) as those above. For example, 37.792242 would be good, whereas 37.7823423425 would be bad. ...
hi, i need to change locale in the thread to parse double with strtod() correctly, i'm using setlocale() for this (C++). is it thread safe? UPD: another problem. when i invoke setlocale() in main function it doesn't effect in other routines deeper. why??? there are a lot of code, so it's problematic to write the chunk. ...
Hi all, I am trying to create a generic class that handles ints, doubles, and strings. However, when trying to instantiate the template class with I get the following error message: error: 'double' is not a valid type for a template constant parameter The instantiation works completely fine with int types, as does the internal code,...