double

Check variable type in C++

So I am currently learning C++ and decided to make a program that tests my skills I have learned so far. Now in my code I want to check if the value that the user enters is a double, if it is not a double I will put a if loop and ask them to reenter it. The problem I have is how do I go about checking what type of variable the user enter...

Should I use decimal, float or double for this simple math result?

Hi folks, I'm doing some really simple math and saving the result to a MS SQL2008 DB. I'm averaging out the some numbers, which are byte values between 1<->5. I wish to record probably 2 decimal places only. I don't care about rounding for the 2nd decimal place (eg. a 1.155 == 1.5 or 1.6 .. i'm not too phased). So .. should i store th...

How do you round a Double down to the nearest integer in VB .NET?

How do you round a Double down to the nearest integer in VB .NET? ...

Java doesn't seem to be comparing Doubles right.

I created a Linked List, with insert, search and remove functions. I also created a iterator for it. Now, suppose I do this: myList<Integer> test = new myList(); test.insert(30); test.insert(20); test.insert(10); myList.iterator it = test.search(20); if(it.hasNext()) System.out.println(it.next()); And voila, it works (it prints th...

Java: Double Value Comparison

Do we need to be careful when comparing a double value against zero? if ( someAmount <= 0){ ..... } ...

What's the recommended workaround if numeric_limits<double>::has_infinity is false?

I need to check a double value for infinity in a C++ app on Linux. On most platforms this works by comparing with std::numeric_limits<double>::infinity(). However, on some old platforms (RedHat 9 for example, with gcc 3.2.2) this is not available, and std::numeric_limits<double>::has_infinity is false there. What workaround would you re...

Make double-precision default in g77, Fortran compiler

Is there an analog of the "-fdefault-real-8" gfortran (the GNU Fortran 95 compiler) option in g77 (the GNU Fortran 77 compiler)? This option sets the default real type to an 8-byte wide type. I currently have code where single-precision arithmetic is limiting my accuracy, and so I need double-precision. (It's not just intermediate val...

How to create an NSMutableArray of floating point values

I'm new to Objective-C and iPhone development, and I'm trying to store floating-point values in an NSMutableArray, but when I do I get an error saying "incompatible type for argument 1 of 'addObject". What am I doing wrong? I'm trying to create an array of doubles that I can perform math calculations with. ...

[C/C++] double to hex string & hex string to double

Hi, What I'm trying to do is to convert a double to hex string and then back to double. The following code does conversion double-to-hex string. char * double2HexString(double a) { char *buf = new char[17]; // double is 8-byte long, so we have 2*8 + terminating \0 char *d2c; d2c = (char *) &a; char *n = buf; int i; f...

Passing a million numbers from java to matlab?

I have a bit of code which runs in 10.919 s. Profiling it shows that 10.182 s are wasted in opaque.double Which is called when I use jClass.GetArrays(jArray1,jArray2); struct.prop1 = double(jArray1); struct.prop2 = double(jArray1); What can be done? I have to use Java to interact with external API. EDIT: I used the following hac...

Float in Database to ? in .NET

If you have a float in MSSQLServer, to what do you map this in .NET? Can you convert it to Double or will you loose numbers? thx, Lieven Cardoen ...

SIMD on an Array of Doubles?

I'm doing some work where SIMD is required and I need to do operations on an array of doubles. Do any of the mainstream architectures support this? I've only seen floating point operations. Thanks in Advance, Stefan ...

PHPExcel: scientific notation of double/float

The problem is the following: We are creating an instance of a class testObject and fill a var with a double. A class TestExcel extends from PhpExcel and when submitting the object testObject into the constructor we get a scientific notation of the var when we do a var_dump. Can anyone help us out. My colleagues and I don't understand ...

Double precision problems on .NET

I have a simple C# function: public static double Floor(double value, double step) { return Math.Floor(value / step) * step; } That calculates the higher number, lower than or equal to "value", that is multiple of "step". But it lacks precision, as seen in the following tests: [TestMethod()] public void Fl...

Checking if a double (or float) is nan in C++

is there an isnan() function? p.s. I'm in mingw (if that makes a difference) UPDATE Thanks for the responses I had this solved by using isnan() form <math.h>, which doesn't exist in <cmath>, which I was #includeing at first. ...

NSTimeInterval to readable NSNumber

NSTimeInterval == double; (e.g. 169.12345666663) How can I round up this double so that there are only 2 digits left after the "dot"? It would be very good if the result is a NSNumber. ...

Double.TryParse or Double.Convert - what is faster and more safe?

My application reads an Excel file using VSTO and adds read data to a StringDictionary. It adds only data that is a number with few digits (1000 1000,2 1000,34 - comma is a delimiter in Russian standards). What is better to check current string being appropriate number? object data, string key; // data had read try { Convert.ToDoubl...

Numerical optimization...

Hi there I was wondering which Integer or Float types are the fastest.. i was thinking byte is faster than integer because it has a smaller range. Some people told me .. that in some cases integer is faster than a byte. second question : The GPU is on his way to World Domination .. so i asked myself : Can a Double "be faster" than a I...

C# Converting 20 digit precision double to string and back again

In C#. I have a double (which I've extracted from a database) that has 20 digit precision. In Visual Studio (using QuickWatch) I can see the value of the double to be = 0.00034101243963859839. I want to display this value in a textbox and then have it be the same value when I take it out and convert it back into a double. But I alway...

C: What does it mean for a double to be == -0?

I was just using gdb to print out a value of a double and to my surprise it printed -0 What is a double of -0 value mean in C? By the way when I checked it's equality with 0 it returned true: To do the comparison I just did the following in gdb > print some_double -0 > print some_double == 0 1 ...