Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
pigdog
Apr 23, 2004

by Smythe

shrughes posted:

Floating point for monetary values isn't necessarily a coding horror.
It's a fairly strong smell (Primitive Obsession) of a coding horror. Money isn't just a number. You can't handle monetary amounts the same way as any old floating point value, i.e. round them up and down by common math rules, and in many cases there are concepts such as currencies to keep track of. In most applications it's very appopriate to represent money with a dedicated class.

Adbot
ADBOT LOVES YOU

PrBacterio
Jul 19, 2000

shrughes posted:

Floating point for monetary values isn't necessarily a coding horror.
Yes it is, what are you talking about? Even though in that case I hadn't even noticed it at first because of the bigger horrors that are present in that example :eng99:

ijustam
Jun 20, 2005

shrughes posted:

Floating point for monetary values isn't necessarily a coding horror.

oh man here we go :can:

shrughes
Oct 11, 2008

(call/cc call/cc)

PrBacterio posted:

Yes it is, what are you talking about? Even though in that case I hadn't even noticed it at first because of the bigger horrors that are present in that example :eng99:

Realtime trading systems, apparently.
http://news.ycombinator.com/item?id=4161178

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

shrughes posted:

Realtime trading systems, apparently.
http://news.ycombinator.com/item?id=4161178

But that's a drastically different context to what is suggested by "double salary = ...", if not something of an exceptional case. Are there any situations in which it would be sensible to represent somebody's salary or hourly wage with a floating-point number?

Bhaal
Jul 13, 2001
I ain't going down alone
Dr. Infant, MD
I think his point is more that, like the use of goto, representing monetary values as floats isn't an automatic horror.

hobbesmaster
Jan 28, 2008

shrughes posted:

Realtime trading systems, apparently.
http://news.ycombinator.com/item?id=4161178

That looks like a good way to be ruined in an audit.

It may be at least not fundamentally a horrible idea if you're doing statistics or something and not accounting.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

hobbesmaster posted:

That looks like a good way to be ruined in an audit.

Not really? In terms of deciding which trades to perform you don't actually need the exact values. And no-one audits your HFT algorithms.

Essentially, floating-point is fine if using an approximation of the actual amount is fine. In most cases where money is used (e.g. accounting) that's definitely not the case, but in some cases (such as the decision-making part of HFT), it is acceptable.

hobbesmaster
Jan 28, 2008

Jabor posted:

Not really? In terms of deciding which trades to perform you don't actually need the exact values. And no-one audits your HFT algorithms.

Essentially, floating-point is fine if using an approximation of the actual amount is fine. In most cases where money is used (e.g. accounting) that's definitely not the case, but in some cases (such as the decision-making part of HFT), it is acceptable.

I misread that, I thought thy were talking about executing trades using floating point for a moment there.

That would be the not accounting statistics I said was an exception... Using doubles for a salary in an example is a horror though.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

shrughes posted:

Realtime trading systems, apparently.
http://news.ycombinator.com/item?id=4161178

That's not "real money" at that stage and I'll bet you the systems that reconcile the trades on the back end and hand out money are arbitrary precision.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


shrughes posted:

Floating point for monetary values isn't necessarily a coding horror.



e:

trex eaterofcadrs posted:

That's not "real money"

Doc Hawkins fucked around with this message at 05:10 on Jul 1, 2012

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
bitcoin is a horror but (mostly) not a coding one and it doesn't use FP to store values

het
Nov 14, 2002

A dark black past
is my most valued
possession

Aleksei Vasiliev posted:

bitcoin is a horror but (mostly) not a coding one and it doesn't use FP to store values
At least one of the sites actually did use floating point for values, which is what I'm assuming Doc Hawkins is referencing.

Zombywuf
Mar 29, 2008

shrughes posted:

Realtime trading systems, apparently.
http://news.ycombinator.com/item?id=4161178

quote:

For simple accounting, it wouldn't be slower. The issue is analytical code, e.g.:
code:
    int price = getPrice(symbol);
    double signal = exp(...) * ((double)price);
    if (signal > threshold) {
        buy(symbol);
    }
The point is to avoid converting from int to double every single time you need to do a calculation.

Do they not teach fixed point arithmetic in schools any more?* There's not even a mention of floats being useful for vectorising on modern CPUs, you know, modern like made in the last 10 years.

Given the trillions of HFT transactions that go on every day (hour?), I wonder what the total dollar amount of rounding error is present in our financial system.

* disclaimer: I was never taught fixed point arithmetic in school, but I'd at least heard of it.

baquerd
Jul 2, 2007

by FactsAreUseless

Zombywuf posted:

Given the trillions of HFT transactions that go on every day (hour?), I wonder what the total dollar amount of rounding error is present in our financial system.

Regardless of what is being used for HFT trading, the EOD accounting is still done with systems that track every last fraction of a cent actually made/lost so it won't really be that much.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.

baquerd posted:

Regardless of what is being used for HFT trading, the EOD accounting is still done with systems that track every last fraction of a cent actually made/lost so it won't really be that much.
a bigger wtf moment I ever in commercial development had involved sorting a list of points in a class where x/y/z coordinates were stored as doubles. I wrote an algorithm that would sort by x coordinate, then y coordinate, then z coordinate... I got very, very weird results.

Zombywuf
Mar 29, 2008

baquerd posted:

Regardless of what is being used for HFT trading, the EOD accounting is still done with systems that track every last fraction of a cent actually made/lost so it won't really be that much.

It's more a critique of the efficient market hypothesis.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Tangential: Doesn't at least one HFT group use OCaml, the language where you can't bat an eye at a float without boxing it?

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Mustach posted:

Tangential: Doesn't at least one HFT group use OCaml, the language where you can't bat an eye at a float without boxing it?

Jane St Capital IIRC

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine
My general notion has been, for my web app, I'm fine with displaying currency as a float (since that's what PHP's money_format() does, which might be a horror in itself, and the precision is more than sufficient for the currency values I'm dealing with), but never do math on it as a float. There's a reason PHP has the bcmath extension. Even better would be if PHP gave us a currency datatype, but we have what we have.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Mustach posted:

Tangential: Doesn't at least one HFT group use OCaml, the language where you can't bat an eye at a float without boxing it?

Wow, I wouldn't believe it if I hadn't seen their blog where they're still bragging about it. I mean granted it's probably a typical finance office where their HFT guy is literally just that one guy feeding numbers into a black box.

If you're going to build a high-performance system on something that likes to box and generally isn't C, you at least have to pick something on the JVM. There's no way the massive OCaml community is producing anything like Hotspot to make your boxing work faster.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

ultramiraculous posted:

Wow, I wouldn't believe it if I hadn't seen their blog where they're still bragging about it. I mean granted it's probably a typical finance office where their HFT guy is literally just that one guy feeding numbers into a black box.

If you're going to build a high-performance system on something that likes to box and generally isn't C, you at least have to pick something on the JVM. There's no way the massive OCaml community is producing anything like Hotspot to make your boxing work faster.

lol

takamoron
Mar 27, 2011

practice nonviolence plz

ultramiraculous posted:

Wow, I wouldn't believe it if I hadn't seen their blog where they're still bragging about it. I mean granted it's probably a typical finance office where their HFT guy is literally just that one guy feeding numbers into a black box.

If you're going to build a high-performance system on something that likes to box and generally isn't C, you at least have to pick something on the JVM. There's no way the massive OCaml community is producing anything like Hotspot to make your boxing work faster.

Isn't the idea in using OCaml or Haskell that they allow for better/ easier parallelization, and that is something that HFT relies on for speed?

hobbesmaster
Jan 28, 2008

takamoron posted:

Isn't the idea in using OCaml or Haskell that they allow for better/ easier parallelization, and that is something that HFT relies on for speed?

Yes. Haskell beats OCaml hands down though...

MononcQc
May 29, 2007

OCaml is usually pretty bad for parallel computing due to having a GIL that shits a lot of stuff up.

As far as I know, OCaml is fast due to its apparently good compiler that can optimizes lots of stuff due to its type system. MLs and their derivatives have had some pretty interesting compiler research through the years. I figure (pure speculation) that this helped OCaml's compiler indirectly.

ymgve
Jan 2, 2004


:dukedog:
Offensive Clock
Isn't HFT the guys that send half a network packet out on the wire before they even know what's going in it? I'm surprised they use something other than pure assembly.

MononcQc
May 29, 2007

ymgve posted:

Isn't HFT the guys that send half a network packet out on the wire before they even know what's going in it? I'm surprised they use something other than pure assembly.

Well, you also want to have as few errors as possible when handling money like that. I figure a high level language is more useful in that perspective.

E: OCaml works well with Coq, a tool for formal proofs.

MononcQc fucked around with this message at 06:50 on Jul 2, 2012

hobbesmaster
Jan 28, 2008

ymgve posted:

Isn't HFT the guys that send half a network packet out on the wire before they even know what's going in it? I'm surprised they use something other than pure assembly.

I imagine there are different levels of hft, not all types of hft can rely on that kind of stuff.

etcetera08
Sep 11, 2008

https://bugs.php.net/bug.php?id=18556

Ten years later...

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

quote:

Why is this bug still not fixed? Not only class names are affected but function names aswell:

<?php
setlocale(LC_ALL, 'tr_TR.UTF-8');

class InfoBlob {

public static function Intresting() {
return 'is it not?';
}
}

echo (infoBlob::intresting()); // works lowercase i function and class.
echo (infoBlob::Intresting()); // fails uppercase i function
echo (InfoBlob::intresting()); // fails uppercase i class
?>

PHP: Intresting, is it not?

Zombywuf
Mar 29, 2008

ymgve posted:

Isn't HFT the guys that send half a network packet out on the wire before they even know what's going in it? I'm surprised they use something other than pure assembly.

Well, you have to wonder if they really are the atomic superman coders they claim to be. Most high finance types think of themselves as gods amongst men, I suspect that the HFT guys have no more idea what they're doing that the rest of the tech industry.

SirViver
Oct 22, 2008

Hammerite posted:

PHP: Intresting, is it not?
Well, to be fair, Turkish upper/lowercase behavior is a common trap. Of course this doesn't excuse it still not being fixed.

E: \/\/\/ :downs:

SirViver fucked around with this message at 12:15 on Jul 2, 2012

that awful man
Feb 18, 2007

YOSPOS, bitch

SirViver posted:

Well, to be fair, Turkish upper/lowercase behavior is a common trap. Of course this doesn't excuse it still not being fixed.

They misspelled "interesting".

qntm
Jun 17, 2009

The real horror is that function calls are case-insensitive :psyduck:

hobbesmaster
Jan 28, 2008

qntm posted:

The real horror is that function calls are case-insensitive :psyduck:

FORTRAN would like a word.

that awful man
Feb 18, 2007

YOSPOS, bitch

qntm posted:

The real horror is that function calls are case-insensitive :psyduck:

There's nothing wrong with case-insensitive identifiers.

The real horror is that function names are case-insensitive, but variable names aren't.

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

that awful man posted:

There's nothing wrong with case-insensitive identifiers.

The real horror is that function names are case-insensitive, but variable names aren't.

Variable names aren't, but array keys are.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Golbez posted:

Variable names aren't, but array keys are.

?

code:
$x = 'fart';
echo $X, 'poop', $x;
$y['butt'] = 'fart';
echo $y['BUTT'], 'poop', $y['butt'];
code:
<br />
<b>Notice</b>:  Undefined variable: X  on line <b>2</b><br />
poopfart<br />
<b>Notice</b>:  Undefined index: BUTT  on line <b>4</b><br />
poopfart

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

Hammerite posted:

?

code:
$x = 'fart';
echo $X, 'poop', $x;
$y['butt'] = 'fart';
echo $y['BUTT'], 'poop', $y['butt'];
code:
<br />
<b>Notice</b>:  Undefined variable: X  on line <b>2</b><br />
poopfart<br />
<b>Notice</b>:  Undefined index: BUTT  on line <b>4</b><br />
poopfart
OK, so variable names are. :P

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Zombywuf posted:

Well, you have to wonder if they really are the atomic superman coders they claim to be. Most high finance types think of themselves as gods amongst men, I suspect that the HFT guys have no more idea what they're doing that the rest of the tech industry.

I wonder if they're like a lot of really smart guys in professions that use programming rather than being in a profession about programming. Take the typical1 code written by a scientist...yuck.

1 Not that I have a lot of experience looking at scientific code, but the little bit that I have is not pretty.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply