Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
mortoray
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
8 ms
·
31.
▲
by
mortoray
11y ago
I agree my initial examples were not clear enough to illustrate the problem precisely. I've added a section now about idempotance and how this slight varation in floating point is causing my original problem. Your point about floating
32.
▲
by
mortoray
11y ago
This is the "correct" behaviour of `floor` obviously, but the unexpected part has to do with floating point accuracy and use domains. Numbers will end up slightly lower or higher than an expected value simply due to accuracy in ca
33.
▲
by
mortoray
11y ago
I suppose in hindsight my example doesn't look as disturbing as it's meant to. :) It's hard to show concise examples that truly show how this little bit of error eventually compounds and destabilizes a calculation.
34.
▲
by
mortoray
11y ago
I'm not sure 80-bit floats are a thing of the past. Many calculations still benefit from the extended precision compared to 64-bit. The issue also crops up agian on some platforms that can do 128-bit float, but are then truncated down
35.
▲
by
mortoray
11y ago
I do mention if you simply increase the length of the formatted string you can do round-trip. It should be noted however (as I do) that the decimal number is still not equivalent to the actual floating point number, only that when converted
36.
▲
by
mortoray
11y ago
I (the author) agree. I'm mainly trying to point out all the issues with floating point rather than give a full solution. I believe the problem stems from people just not realizing a lot of these problems. Certainly I'm not offeri
37.
▲
by
mortoray
11y ago
Yes, named arguments are a nice solution. Espeically if it can be forced (only passable by name).
38.
▲
by
mortoray
11y ago
This would essentially be the enum option: giving names to constants. But this way wouldn't enforce the convention, you could still use `true` or `false`.
39.
▲
by
mortoray
11y ago
That's a nice idea. It'd also limit the scope so it has a short name, instead of something like `DoSomethingLogging`.
40.
▲
Bringing blurry device independent pixels into focus
(mortoray.com)
4 points
by
mortoray
12y ago
|
0 comments
41.
▲
by
mortoray
12y ago
I know in some situations you can use dot product and it's an optimization I will apply. A bit more care must be taken though. The input must be unit vectors and the output can be positive or negative. I tend to do my first code as log
42.
▲
Quelling the floating point demon in my line rendering code
(mortoray.com)
11 points
by
mortoray
12y ago
|
3 comments
43.
▲
Cubist artwork with the help of a GPU
(mortoray.com)
2 points
by
mortoray
12y ago
|
0 comments
44.
▲
A secure and private browser sandbox
(mortoray.com)
2 points
by
mortoray
12y ago
|
0 comments
45.
▲
Blocking JavaScript seems like a good idea
(mortoray.com)
6 points
by
mortoray
12y ago
|
1 comments
46.
▲
Using macros to simplify type visitors and enums
(mortoray.com)
4 points
by
mortoray
12y ago
|
0 comments
47.
▲
The amortized cost of vector.insert is 3
(mortoray.com)
4 points
by
mortoray
12y ago
|
0 comments
48.
▲
What is amortized time?
(mortoray.com)
2 points
by
mortoray
12y ago
|
0 comments
49.
▲
The false abstraction antipattern
(mortoray.com)
3 points
by
mortoray
12y ago
|
0 comments
50.
▲
Why social media needs to manipulate you
(mortoray.com)
6 points
by
mortoray
12y ago
|
0 comments
51.
▲
A curious non-OOP virtual inheritance for a GPU
(mortoray.com)
3 points
by
mortoray
12y ago
|
0 comments
52.
▲
Removing code by adding features
(mortoray.com)
2 points
by
mortoray
12y ago
|
0 comments
53.
▲
by
mortoray
12y ago
No, I'm saying you have coordinated the writing to the stack. It's not enough to just swap pointers to the stacks themselves, but you have to know how much data has been written to the stack. Perhaps your description is incomplete
54.
▲
by
mortoray
12y ago
Yes, they are fun. At least in practice the decision to use one or the other would come from variance guarantees. From this view we can define a "practical" meaning to each one. * blocking: very high variance in operation time * l
55.
▲
by
mortoray
12y ago
The problem with this approach is that it requires coordination on when the swap of the two stacks is done. Using CAS doesn't really help. The consumer doesn't know if the producer is currently writing into the stack or not. It st
56.
▲
by
mortoray
12y ago
That's essentially what pointers to string literals are. They are indexes into a constant data segment which contains the actual strings.
57.
▲
by
mortoray
12y ago
I was unaware of the PAUSE function. It certainly did belong inside my spin-loop. The other recommendation of cache-line alignment I was following, and it does make a difference.
58.
▲
by
mortoray
12y ago
Well, only one side of the queue was wait-free. The other side, the consumer, was a whole mess of queues and buffers. It's simply the process of putting something in the queue that is fast. Getting out of that queue is a terribly slow
59.
▲
by
mortoray
12y ago
I think I better understand what "lock-free" means now, thank you for the explanation. I will review what I said in my article and ensure I'm not spreading any misinformation. When I learned of lock-free I was presented with
60.
▲
by
mortoray
12y ago
Yes, a string-literal type would be very helpful. In my Leaf language I have literal types. I think they offer some good optimiation abilities.
More ›