double

Most Efficient Way to Test Object Type

I have values stored as strings in a DataTable where each value could really represent an int, double, or string (they were all converted to strings during an import process from an external data source). I need to test and see what type each value really is. What is more efficient for the application (or is there no practical differenc...

Can cout alter variables somehow?

So I have a function that looks something like this: float function(){ float x = SomeValue; return x / SomeOtherValue; } At some point, this function overflows and returns a really large negative value. To try and track down exactly where this was happening, I added a cout statement so that the function looked like this: flo...

Why would I use 2's complement to compare two doubles instead of comparing their differences against an epsilon value?

Referenced here and here...Why would I use two's complement over an epsilon method? It seems like the epsilon method would be good enough for most cases. Update: I'm purely looking for a theoretical reason why you'd use one over the other. I've always used the epsilon method. Has anyone used the 2's complement comparison successfu...

How to convert a unmanaged double to a managed string?

From managed c++, I am calling an unmanaged c++ method which returns a double. How can I convert this double into a managed string? Sorry if this is a stupid question, I'm still very new with C++ in .net. Thanks! ...

Are doubles faster than floats in c#?

I'm writing an application which reads large arrays of floats and performs some simple operations with them. I'm using floats because I thought it'd be faster than doubles, but after doing some research I've found that there's some confusion about this topic. Can anyone elaborate on this? Thanks. ...

Letters within integers. What are they?

This is an excerpt of code from a class I am working with in Java (below). Obviously the code is defining a static variable named EPSILON with the data type double. What I don't understand is the "1E-14" part. What kind of number is that? What does it mean? final double EPSILON = 1E-14; ...

Double quotes in Oracle Alias

Hi, I am having fickle of problem in Oracle 9i select 1"FirstColumn" from dual; Oracle throwing error while executing above query. ORA-03001: unimplemented feature in my Production server. The Same query is working fine in my Validation server. Both servers are with Oracle 9i Any one have Idea what's wrong...? Is this something conf...

Converting a byte() array to a double in VB.Net

Hi, I have this situation. I have a real stored in a varbinary field in a sql 2005 database. As I can't convert a varbinary to a real in sql 2005, I'm trying to do that in vb.net. That field gets stored as a byte() array in a DataTable. Now I would like to read that byte() into a double, or decimal variable. But I don't have much of a ...

Applications using Decimal versus double . . .

I wanted to see if folks were using decimal for financial applications instead of double. I have seen lots of folks using double all over the place with unintended consequences . . Do you see others making this mistake . . . ...

Compare double in VBA precision problem

I have trouble comparing 2 double in Excel VBA suppose that I have the following code Dim a as double Dim b as double a = 0.15 b = 0.01 After a few manipulations on b, b is now equal to 0.6 however the imprecision related to the double data type gives me headache because if a = b then //this will never trigger end if Do you know...

Which is the best way to compare the integer part of two non-integer numbers?

I need to compare the integer part of two doubles for inequality and I'm currently doing this: int iA = (int)dA; int iB = (int)dB; if( iA != iB ) { ... } but I wonder if there's a better approach than this. Thanks. If I used Math.Truncate() instead of a cast to int, would it still be accurate to compare the two resulting double...

Firefox sending request twice

I'm trying to process a credit card transaction in .net and it works perfectly in Safari, Opera, and IE. When I try the same transaction in Firefox it sends two requests and I end up with a double charged card. From a quick search on Google it seems that this is an issue with Firebug but I am unable to find a way to stop this double post...

Smarty replace text with double quotes

I have the following string in the smarty (php templating system) variable $test: <img height="113" width="150" alt="Sunset" src="/test.jpg"/> I want to add "em" to the height and width like this: {$test|replace:'" w':'em" w'|replace:'" a':'em" a'} But this doesn't work... What's the problem and the solution? ...

What column type in Oracle can take full range of java double values

What column type in Oracle 10g can be used to store any value of java double up to and including Double.MAX_VALUE and Double.MIN_VALUE? ...

static_cast confusion caused by inconsistencies

Why whenever I compile and run the following code in Visual Studio 2008: double value1 = 10.5; double value2 = 15.5; int whole_number = value1 + value2; Console::WriteLine(whole_number); I get an incorrect value of 26 while the answer is 25. However when I use static casts on the doubles, I get the right answer which is 25. How can ...

Retain precision with Doubles in java.

public class doublePrecision { public static void main(String[] args) { double total = 0; total += 5.6; total += 5.8; System.out.println(total); } } Which returns 11.399999999999 Okay clarifying the question a bit, how would i get this to just print (or be able to use it as) 11.4? ...

Using double, return string

In the application I'm writing, one of the methods allows for the numbers the user entered to be turned into letters. For example, the user will be entering grades (as doubles) and the program will decide (when the criteria is met) to return the letter associated with the number. Initially, I had it written like this: public void GetGra...

Decimal vs Double Speed

I write financial applications where I constantly battle the decision to use a double vs using a decimal. All of my math works on numbers with no more than 5 decimal places and are not larger than ~100,000. I have a feeling that all of these can be represented as doubles anyways without rounding error, but have never been sure. I would...

How do I convert a double into a string in C++?

I need to store a double as a string. I know I can use printf if I wanted to display it, but I just want to store it in a string variable so that I can store it in a map later. ...

Float or Double Special Value

In my application i have double (or float) variables that might be "empty", as in holding no valid value. How can i represent this condition with the built in types float and double? One option would be a wrapper that has a float ad a boolean, but that can´t work, as my libraries have containers that store doubles and not objects that b...