News for hackers. Stuff that matters.

hurrrrrrrr

Re:Cosine Implementation in C on Friday March 31, 2023 @11:31AM (#35388622)
Looks like angle sum identity.

    cos(x+y) = cos(x)*cos(y) - sin(x)*sin(y)     (always)
             ~ cos(x)*1      - sin(x)*y          (if y small)
Can't speak for the validity of small angle assumptions though.
Re:Cosine Implementation in C on Friday March 31, 2023 @11:24AM (#35388504)
Polynomials with the coefficients defined in the sin and cos arrays (and likely in the referenced literature).
Re:Cosine Implementation in C on Friday March 31, 2023 @10:55AM (#35388051)
It's an easy way to return nan and set FE_INVALID. If you're not worried about floating point exceptions you can just return NaN directly. Idk how much C# even guarantees about the floating point operations and if it's applicable there.

https://en.cppreference.com/w/cpp/numeric/fenv/FE_exceptions

Re:Optimizations Enabled by -ffast-Math on Wednesday October 20, 2021 @08:24AM (#28929806)
>Certainly do not use finite-math-only when dealing with external data.

so... never?

Re:Why do printers still suck? on Wednesday November 04, 2020 @10:34AM (#24989916)
Because the danger of fume is negligible. It's a thing if you put it in a 2m^2 storeroom and sniff the exhaust for 8 hours straight but in any other case it doesn't come close to concentrations you get on the street anyway.
Re:Fast Inverse Square Root on Tuesday November 03, 2020 @08:35AM (#24979485)
In isolation, no. You could instead spend your time optimizing something else that's currently slower and speed that up instead.
Re:Fast Inverse Square Root on Tuesday November 03, 2020 @08:27AM (#24979411)
The compiler is not beholden to the standard library but the standard. So all modern compilers come with a bit of knowledge of how standard library functions like memcpy are supposed to behave and as long as the visible effect is the same it's allowed to do anything it wants. So instead of calling the function memcpy for a size of 4, it can e.g. just use a mov instruction to move the value from a float to an integer register. [1] It does additional analysis on how the values are used and maybe it doesn't even need to move the value at all, but that's the gist of it.

[1] https://gcc.godbolt.org/z/x4P7jE

Re:I Hate Coordinate Systems on Friday October 30, 2020 @07:43AM (#24941204)
I think he has that correct. Ime it's split on east/north vs. north/east but wgs84 is very dominant with lat/lon.
> I think the only reason people enjoy it is the fact that they have not gotten a chance to really spend time in a good tiling window manager on X11/GNU/Linux.

I did and switched back to floating. AMA

Re:USB3: Why it's a bit harder than USB2 on Wednesday October 07, 2020 @11:22AM (#24709172)
And how much more do they cost in comparison with hooking a few copper wires to a simple copper plug manufactured in china?
> Programming languages will generally crash at runtime when an unrecoverable error occurs (index out of bounds, memory allocation failed, null pointer, etc).

JS would like to have a word with you.

Re:Kitty – A fast, featureful, GPU based terminal emulator on Thursday October 01, 2020 @12:29PM (#24652893)
It is useful with some badly written build systems that think they have to write every invocation of gcc to stdout. Like every badly written Makefile out there. Or `cat myapp/log/yesterday.log`.

You can work around both but it's clunky. And also it's a thing that's not a must have, just a nice(r) to have.

Re:First Impressions of Rust on Friday August 07, 2020 @10:18AM (#24082099)
Maybe, maybe not. Is the potential benefit even worth fighting over? Style is just full of so many subjective details that every discussion ends in. And everybody has their favorite it's un-fucking-readable. My oppinion converged on "Fight it out and tell me what options in $formatter I need to set. Don't even tell me reasonings, just the options. leaves room". I'd rather drink coffee than have the next horizontal real estate vs. parameter alignment debate.

The argument to match clauses/scoping for example is weird in a world where a formatter automatically applies indentation. It might make sense when you have to manually check them on print-outs without an Editor. I'd argue GNU style fulfills that role even better or Horstmann if you care about vertical real estate (or be daring and combine the two). And now everyone hates me.

Re:Shit – An implementation of Git using POSIX shell on Wednesday February 12, 2020 @11:39AM (#22310274)
On the other hand I understand de data model of git and can't to the most basic shit without looking up which invocation I need via search engine/man pages. Like... deleting a branch `git branch -d` (-D for forced deletion). Deleting a remote? `git remote rm`. Knowing the model teaches me nothing about the ui.
Re:ZZ is a modern formally provable dialect of C on Wednesday February 05, 2020 @09:30AM (#22246923)
But if we get rid of a whole class of bugs and vulnerabilities, the number of bugs will go down, no?
Re:ZZ is a modern formally provable dialect of C on Wednesday February 05, 2020 @09:26AM (#22246878)
>Do I really know how much cycles/stack it takes to do std::sort(a.begin(), a.end()); in that specific platform? No, so I cannot trust it.

I also don't know how many cycles it takes for my implementation of quicksort apart from checking the output of a specific compiler and counting instructions. C is not, was not and will never be a portable assembler.

Rust in general will panic on memory allocation failure. There was some discussion about oom handling a while back but I don't know the current state.
Re:Germans Grow Frustrated with Their Slow-Poke Internet on Tuesday August 06, 2019 @08:50AM (#20624639)
Competence doesn't seem to be a requirement in these positions.
Re:What Is Idempotence? on Friday April 05, 2019 @05:22AM (#19580956)
Which makes it a different function `assign_invert(x) = assign(invert(x))`