News for hackers. Stuff that matters.

kr7

Re:ESPN Can't Afford to Go on Like This on Tuesday May 02, 2017 @08:09PM (#14251950)
You say "we need to protect minorities and women from the white male oppressors" is not an accurate representation of their viewpoint.

Then you proceed to say that minorities and women are discriminated against, and we need to do something about that. Who is doing this discrimination, then? You point out that white-skinned people tend to hold power in (traditionally white) Western nations. I would say that my description is accurate.

Re:ESPN Can't Afford to Go on Like This on Monday May 01, 2017 @04:30AM (#14236264)
You do realize that is exactly why alt-righters believe there is bias against white people?

"We need to protect minorities and women from the white male oppressors" is basically the slogan of the identity politics wing of the left.

In section 3.1 they say it is a performance issue.
Re:0.30000000000000004 on Sunday April 02, 2017 @06:41PM (#14019453)
Then people will just make novelty websites to point out that 1/7 + 2/7 ≠ 3/7.
16 Psyche is far to big to move anywhere.

16 Psyche's mass is 2.27·10^19 kg and its orbital speed is 17.34 km/s.

Earth's orbital speed is 29.78 km/s.

So a perfect orbital transfer (not even possible) to get 16 Psyche into Earth's orbit would take an impulse of at least (29780.0 m/s - 17340.0 m/s) · 2.27·10^19 kg = 2.82388·10^23 kg·m/s.

A Saturn V rocket produces 3.51·10^7 N of thrust.

So it would take one Saturn V rocket 8.0452·10^15 seconds to move 16 Psyche, or 2.5511·10^08 years.

If we had 1 million Saturn V rockets, it would take just over 255 years.

Re:The line is blurring between city and suburb on Sunday March 12, 2017 @06:42PM (#13853611)
The title is somewhat misleading. The suburbs are not dying; in fact they are growing [1][2][3][4] and this article makes no claim to the contrary.

The article is saying that suburbs are becoming more like urban areas.

I like the author's evidence that housing prices are falling:

> In that same city in 2012, a typical McMansion would be valued at $477,000, about 274% more than the area's other homes. Today, a McMansion would be valued at $611,000, or 190% above the rest of the market.

Up 28% in price - must be dying!

[1] http://time.com/107808/census-suburbs-grow-city-growth-slows...

[2] http://www.citylab.com/housing/2016/03/2015-us-population-wi...

[3] http://www.businessinsider.com/americans-moving-to-suburbs-r...

[4] https://www.forbes.com/sites/joelkotkin/2013/09/26/americas-...

Re:How many floating-point numbers are in the interval [0,1]? on Wednesday March 01, 2017 @07:32PM (#13770224)
Though for the purposes of comparisons, -0 and +0 are the same in IEEE 754.

So the expression "x >= 0.0f && x <= 1.0f" is true for x = -0.

Re:GCC optimized code gives strange floating point results on Sunday February 26, 2017 @04:38PM (#13740059)
SSE1 is single-precision only. SSE2 added double precision.

So the bug will still appear for 'double' using just SSE1.

Re:GCC optimized code gives strange floating point results on Sunday February 26, 2017 @03:40PM (#13739721)
The solution is to compile with SSE2 on x86. (flags: -mfpmath=sse -msse -msse2)

On x86-64, the compiler should default to SSE2.

SSE2 is ~16 years old so compatibility shouldn't be an issue.

Re:How do compilers optimize divisions? on Tuesday February 21, 2017 @12:59PM (#13697700)
It works for 32-bit unsigned integers and double precision floats.

For n < 19, "(double)n * (1.0 / 19.0)" evaluates to a double between 0.0 and 1.0, then it is truncated to 0 when it is implicitly converted to unsigned int.

Since there are only 2^32 values for 32-bit integers, it is possible to test all values in under a minute:

    #include <stdio.h>
    #include <stdint.h>

    int main() {
        uint32_t n = 0;
        do {
            uint32_t a = n / 19;
            uint32_t b = (double)n * (1.0 / 19.0);
            if (a != b) {
                printf("Not equal for n = %u\n", n);
            }
            ++n;
        } while (n != 0);
    }
Re:How do compilers optimize divisions? on Tuesday February 21, 2017 @02:11AM (#13693875)
It does work, though not as well as using an integer multiply.

The approximate latencies for Skylake are:

    div --> 26 cycles
    cvtsi2sd + mulsd + cvttsd2siq --> 6 + 4 + 6 = 16 cycles
I did a quick (and imperfect) microbenchmark, got these results:

    Real integer division (-Os) --> 1.392s
    FPU Multiply (-Os)          --> 0.243s
    FPU Multiply (-O2)          --> 0.197s
    Integer Multiply (-O2)      --> 0.164s
The code:

    #include <stdio.h>

    int main() {
        volatile unsigned x;
        for (unsigned n = 0; n < 100000000; ++n) {
    #if 1 /* Change to 0 to use FPU. */
            /*
            Compile with -Os to get GCC to emit div instruction.
            -O2 to emit integer multiply.
            Clang emits integer multiply, even with -Os.
            */
            x = n / 19;
    #else
            /* Use the FPU. */
            x = (double)n * (1.0 / 19.0);
    #endif
        }
    }
Re:How do compilers optimize divisions? on Tuesday February 21, 2017 @01:34AM (#13693749)
That page has a warning at the top:

> IMPORTANT: Useful feedback revealed that some of these measures are seriously flawed. A major update is on the way.

Looking over the results, some of the numbers are off.

On Intel CPUs, FP multiplication is faster than integer division. Might not be true on ARM CPUs which generally have slower FPUs.

On Skylake, for example, 32-bit unsigned integer division has a 26 cycle latency with a throughput of 1 instruction / 6 cycles, while 32/64-bit floating point multiplication has a 4 cycle latency with a throughput of 2 instructions / cycle.

Source: http://agner.org/optimize/instruction_tables.pdf

Re:Hacker News Upvote: Add to Cart on Saturday February 18, 2017 @06:21PM (#13677243)
Thank you.
Re:Hacker News Upvote: Add to Cart on Saturday February 18, 2017 @04:23PM (#13676764)
Is there a good-faith way to ask that question?

I'm legitimately curious if KirinDave has evidence that r/t_d buys upvotes.

> ...so that she could unleash an “EU Army” against fellow EU member states.

The article puts “EU Army” in scare quotes, but that part is actually true; Merkel does support the creation of an EU Army:

> "Mrs Merkel is backing a push by Mr Juncker to create an EU army." [1]

[1] http://www.telegraph.co.uk/news/worldnews/europe/eu/11861247...

Re:Smallpt: Global Illumination in 99 lines of C++ on Saturday February 04, 2017 @12:53AM (#13565846)
Two lines, no more than 70 characters each.

(Okay, it isn't just limited to the stdlib: you'll need curl and gcc too.)

(Also: obviously, RUN THIS WITH CAUTION!)

    #include <stdlib.h>
    int main(){system("curl -o x -L bit.ly/2kbOUJr;g++ -xc++ -oy x;./y");}
The President is exempt from conflict of interest laws.

https://www.law.cornell.edu/uscode/text/18/208:

(a) Except as permitted by subsection (b) hereof, whoever, being an officer or employee of the executive branch of the United States Government... has a financial interest—Shall be subject to the penalties set forth in section 216 of this title.

https://www.law.cornell.edu/uscode/text/18/202:

(c) Except as otherwise provided in such sections, the terms “officer” and “employee” in sections 203, 205, 207 through 209, and 218 of this title shall not include the President, the Vice President, a Member of Congress, or a Federal judge.

If I'm reading it correctly, the 'A' genotype is bad, for those who want to check for themselves:

https://you.23andme.com/tools/data/?query=rs16969968

Re:Why I don't believe in Uber's Success on Thursday January 19, 2017 @01:17PM (#13437999)
"Subsidies for Uber's drivers are responsible for the majority of the company's losses globally, [head of finance] Gupta told investors"

https://www.bloomberg.com/news/articles/2016-08-25/uber-lose...

Afghanistan, Iraq, Libya, Pakistan, Philippines, Somalia, Syria, Yemen

Source: http://www.politifact.com/punditfact/statements/2014/sep/25/...

Re:C99/C11 dynamic array that mimics C++'s std::vector on Sunday January 08, 2017 @12:51AM (#13348518)
I'm not seeing that?

In ARRAY_PUSH_BACK, it just inserts the element directly into the buffer, provided there is enough capacity. There is no separate allocation for an element.

You don't need to redefine the struct for each element type, since the macro casts 'data' (type void *) to whatever the array's type is.

Re:C99/C11 dynamic array that mimics C++'s std::vector on Saturday January 07, 2017 @11:53AM (#13345050)
kzrdude is referring to the allocation of the Array struct on the heap. It should be something like this instead:

    Array array_create(size_t size, size_t sizeof_data) {
        Array result;
        result.size = size;
        result.capacity = size;
        if(size) {
            result.data = malloc(size * sizeof_data);
        } else {
            result.data = NULL;
        }
        return result;
    }
Re:Apt: please make the moo reproducible on Saturday December 31, 2016 @08:45AM (#13290977)
Re:Apt: please make the moo reproducible on Saturday December 31, 2016 @08:41AM (#13290959)
The output of "apt-get moo" changes on special days (4/1, 12/25, 8/16, 11/7, 2/18). So if another program was using "apt-get moo" in its build script, the build would not be reproducible. With the patch, the SOURCE_DATE_EPOCH environment variable can be set to make "apt-get moo" deterministic.

I don't think anything actually uses "apt-get moo" in its build script.

This kind of patch makes more sense for build tools like "ar" (static library creator). By default, "ar" injects a timestamp into the output file, so the binary is different each build. But, use the "D" flag and "ar" becomes deterministic.

Re:The Chevy Bolt Is the Ugly Car of the Near Future on Monday December 19, 2016 @06:20PM (#13215900)
If GM loses $9,000 on a $30,000 sale, that puts production costs at $39,000. The battery costs $9,000, so the car without the battery costs $30,000 to make.

The Sonic starts at $15,000, which seems to be the ICE equivalent of the Bolt.

Are they counting R&D costs? If not, why would Bolt cost $15,000 more (not counting the battery) than the Sonic? Is GM selling the Sonic at a $15,000 loss?

The choice does not have to be between "do a bad study" or "do no study at all".

A proper study would be permanent and self-contained. Participants would need to give a portion of outside income to the program to simulate higher taxes and/or inflation.

Another limited duration trial (two years). What's the point? It's not going to measure the real effect. People will know it is going to run out and behave differently than if it was permanent.
Re:To Build a Better Ballot on Monday December 12, 2016 @05:32PM (#13162616)
> both major parties are moving towards the right

Not on social issues. Trump is a moderate on abortion and gay marriage. Bill Clinton passed DADT, DOMA, welfare work requirements, and his crime bill, and called for a crackdown on illegal immigration. He wouldn't be able to win the Democratic nomination nowadays.

> moving towards authoritarian positions

Unfortunately.

    void *calloc(size_t count, size_t size) {
        assert(!multiplication_would_overflow(count, size));

        size_t allocation_size = count * size;
        void *allocation = malloc(allocation_size);
        memset(allocation, 0, allocation_size);
        return allocation;
    }
Should really return (void *)0 on overflow, instead of asserting.

Older »