by Anonymous Coward writes:
on Wednesday August 26, 2009 @04:04AM (#29197957)
I worked with some finance guy who was convinced that the square root of a negative number -x was -sqrt(x), and wouldn't hear otherwise. I hacked sqrt(x) to return sgn(x)*sqrt(fabs(x)), but he complained that when he squared the answer, he didn't get back a negative number. Luckily our code was C99 so I changed his dollar type to be "double complex", made him use the complex sqrt, and changed his print function to display creal(x) - cimag(x). The guy said things worked great. I was glad to hear that, but it still feels wrong that part of our finance system is handling complex number of dollars, whatever that means.
That'll be a problem if you ever have to handle extremally large transactions. Doubles round. Finance guys really hate it when their cents go missing.
Note that he's using doubles. 'Extremely large' here would be bigger than $10^15. If he's in Zimbabwe, or his company has transactions two orders of magnitude bigger than the GDP of the EU, there may be a few dollars lost in rounding. But anything less than that should be safe.
If you're running one of the most popular distributed computing clients out there, you're actually running some of my floating point work, mr. Troll.
If you'd looked at GPs post it'd be obvious that he's talking about taking square roots of dollar amounts, which no financial transaction software should ever do, so doubles are perfectly appropriate here, and probably overkill.
Apparently your dumb ignorant ass missed the part where you overestimated the accuracy of doubles by two orders of magnitude.
Here is a tip. When doing USD financial calculations, AT A MINIMUM you need to be accurate to the PENNY... and in fact the person you replied to even mentioned it..
I wasn't trolling.. I was observing your mistake.. Now I am observing your over-inflated ego and completely ignorant reluctance to find your error.
I dont give a flying fuck what programs you have written in the past
You don't seem to understand the difference between financial modeling and financial transactions.
Apparently your dumb ignorant ass missed the part where square roots of dollar amounts were taken, which clearly points towards some kind of random walk diffusional modeling which has nothing to do with financial transactions and pennies.
If you would have been really clever, you would have noted that what he wanted (complex values for dollars) is mathematically the same as asking for imaginary negative time. Th
You were off on the accuracy by two orders of magnitude, and not on the conservative side either. Now you are making excuses for why that error didnt matter. Really?
You were wrong. Its really that simple. It does not matter if the error matters or not. When errors like that do not matter, it is only through LUCK.
It might have been some average distances on a random walk (for instance as a model for futural prices or interests). If you wait a time t, then the expected distance from your starting point in a Brownian random walk is ~sqrt(t). And if you look into the past, you might get imaginary expected distances:)
complex finance math (Score:3, Funny)
I worked with some finance guy who was convinced that the square root of a negative number -x was -sqrt(x), and wouldn't hear otherwise. I hacked sqrt(x) to return sgn(x)*sqrt(fabs(x)), but he complained that when he squared the answer, he didn't get back a negative number. Luckily our code was C99 so I changed his dollar type to be "double complex", made him use the complex sqrt, and changed his print function to display creal(x) - cimag(x). The guy said things worked great. I was glad to hear that, but it still feels wrong that part of our finance system is handling complex number of dollars, whatever that means.
Re: (Score:2)
That'll be a problem if you ever have to handle extremally large transactions. Doubles round. Finance guys really hate it when their cents go missing.
Note that he's using doubles. 'Extremely large' here would be bigger than $10^15. If he's in Zimbabwe, or his company has transactions two orders of magnitude bigger than the GDP of the EU, there may be a few dollars lost in rounding. But anything less than that should be safe.
Re: (Score:2)
Re: (Score:2)
If you're running one of the most popular distributed computing clients out there, you're actually running some of my floating point work, mr. Troll.
If you'd looked at GPs post it'd be obvious that he's talking about taking square roots of dollar amounts, which no financial transaction software should ever do, so doubles are perfectly appropriate here, and probably overkill.
Re: (Score:2)
Here is a tip. When doing USD financial calculations, AT A MINIMUM you need to be accurate to the PENNY... and in fact the person you replied to even mentioned it
I wasn't trolling.. I was observing your mistake.. Now I am observing your over-inflated ego and completely ignorant reluctance to find your error.
I dont give a flying fuck what programs you have written in the past
Re: (Score:2)
You don't seem to understand the difference between financial modeling and financial transactions.
Apparently your dumb ignorant ass missed the part where square roots of dollar amounts were taken, which clearly points towards some kind of random walk diffusional modeling which has nothing to do with financial transactions and pennies.
If you would have been really clever, you would have noted that what he wanted (complex values for dollars) is mathematically the same as asking for imaginary negative time. Th
Re: (Score:2)
You were wrong. Its really that simple. It does not matter if the error matters or not. When errors like that do not matter, it is only through LUCK.
Re: (Score:1)
It might have been some average distances on a random walk (for instance as a model for futural prices or interests). If you wait a time t, then the expected distance from your starting point in a Brownian random walk is ~sqrt(t). And if you look into the past, you might get imaginary expected distances :)
Re: (Score:1)
The alternative to that dirty hack: finance guy takes remedial algebra
Re: (Score:3, Insightful)
I learned long ago that regular math and financial math follow very different rules.
Re: (Score:3, Funny)
> I was glad to hear that, but it still feels wrong that part of our finance system is handling complex number of dollars, whatever that means.
What? I'm sure most finance guys are adept enough at counting both real and imaginary dollars, so having complex dollars isn't really that complex...
Re: (Score:2, Insightful)
but it still feels wrong that part of our finance system is handling complex number of dollars, whatever that means.
They're called Imaginary dollars, and there's a lot of them about at the moment.
Re: (Score:1)
So now we know who's really responsible for the current financial crisis. :-)
Re: (Score:2)
Shouldn't be a problem as long as the bank has enough imaginary reserve funds to back it up.