HNHacker News
TopNewBestAskShowJobs

piadodjanho

154 karma · joined November 24, 2018

submissionscomments
piadodjanho··on Floating Point Visually Explained (2017)
Weirdly, those two codes behaves differently:

    $ gcc hn.c -O0 -o hn

    for (size_t i; i < (1ul<<46); i++) {
        printf ("%zd\n",i);
        acc += x;
        break;
    }
Without break:

    $ gcc hn.c -O0 -o hn

    for (size_t i; i < (1ul<<46); i++) {
        printf ("%zd\n",i);
        acc += x;
    }
piadodjanho··on Floating Point Visually Explained (2017)
Hm. I don't know.

My reasoning is about how much information can be encoded in the format.

The IEEE-754 double format have 11 bits to encode the exponent and 52 bits to encode the fraction.

Therefore, the multiplying factor from double is in the range: 2^1023 to 2^-1022. To give an idea how large this is, the scientist estimate there are about 10^80 atoms in universe, in base 2 this is "little" less than 2^266.

Most application only don't work with numbers on this magnitude. And the ones that does, don't care so much about precision.

Let me know if there is something wrong with my logic.

piadodjanho··on Floating Point Visually Explained (2017)
lol, how the compiler didn't warn about uninitialized variable
piadodjanho··on Is Sunscreen the New Margarine? (2019)
The issues I enumerated affects both nano and non-nano sunscreen with different degrees.

The most commons concerns specific of the nano version are the skin absorption and free radical creation when expose to UV radiation -- not exclusive of the mineral sunscreen though, azobenzene is also highly unstable.

We often hear about studies done with the nano crystal because are worst. Experiments done with them are more likely to produce a negative result. But this doesn't mean the "macro" version isn't affected as well.

The aspiration concern is very serious one. Some countries bans spray and power mineral sunscreen of any kind.

Just to be clear. I'm not advocating against using them. Every sunscreen has its place, saying one option is better than other is reductive.

For instance, think an Avobenzone + antiox only chemical sunscreen is a good option to minimize the UVA damage and enable the body to produce vitamin D minimizing the damage created by UVA radiation. But they wouldn't be my choice when going to the beach.

Similarly, Mineral sunscreens don't degrade in the sun and block a wide range of UV radiation. But they are bad for marine wild life. They are a good choice for daily facial sunscreen, specially for skin sensitized by "anti aging" treatments.

Again. There is no such thing as the best sunscreen. Each is best in different use cases.

piadodjanho··on Is Sunscreen the New Margarine? (2019)
A sunscreen that blocks UVB, harm marine life [1] and can cause allergic airways inflammation [2] when breathed (inevitable when it dries on your skin) is hardly the best sunscreen in my option.

My personal choice for to vitamin D synthesis is Avobenzone stabilized with ubiquinone.

[1] https://oceanservice.noaa.gov/news/sunscreen-corals.html [2] https://www.sciencedirect.com/science/article/pii/S0041008X1...

piadodjanho··on Is Sunscreen the New Margarine? (2019)
The the most commonly used sunscreen chemical have hormone like activity [1].

https://www.ewg.org/sunscreen/report/the-trouble-with-sunscr...

piadodjanho··on Floating Point Visually Explained (2017)
NaN is NaR (not a real) in posit notation.
piadodjanho··on Floating Point Visually Explained (2017)
Yeah. Gustafons is like, memory is cheap, just use a few hundreds of kb to store the quire. To be fair, he is not HW guy.
piadodjanho··on Floating Point Visually Explained (2017)
I looked at the asm generate from my original example and they generate very different codes, gcc applies other optimization when compiled with -O1.

I've been fighting the compiler to generate a minimal working example of the subnormals, but didn't have any success.

Some things take need to be taken in account (from the top of my head):

- Rounding. You don't want to get stuck in the same number. - The FPU have some accumulator register that are larger than the floating point register. - Using more register than the architecture has it not trivial because the register renaming and code reordering. The CPU might optimize in a way that the data never leaves those register.

Trying to make a mwe, I found this code:

    #include <stdio.h>
    
    int
    main ()
    {
        double x = 5e-324;
        double acc = x;
    
        for (size_t i; i < (1ul<<46); i++) {
                acc += x;
    
        }
    
        printf ("%e\n", acc);
    
        return 0;
    }

Runs is fraction of seconds with -O0:

    gcc double.c -o double -O0
But takes forever (killed after 5 minutes) with -O1:

    gcc double.c -o double -O1
I'm using gcc (Arch Linux 9.3.0-1) 9.3.0 on i7-8700

I also manage to create a code that sometimes run in 1s, but in others would take 30s. Didn't matter if I recompiled.

Floating point is hard.

piadodjanho··on Floating Point Visually Explained (2017)
He also propose the use of an opaque register to accumulate (quire), in contrast to the transparent float register (its a mess, each compiler does what it think is best).

When working with numbers that exceed the posit representation you use the quire to accumulate. At the end of the computation you convert again to posit to store in memory, or store the quire in memory.

In C, it would look like something like:

    posit32_r a, b;
    quire_t q;
    
    q = a; // load posit into quire
    
    q = q + b; // accumulate in quire
    
    a = q; // load quire into posit

> The rest of Gustafson's stuff always sounds like crazy-people talk, to me.

I've read all his papers on posit and agree. But I do believe the idea of encoding exponent with golomb-rice is actually very good and suit most users. The normalization hardware (used in the subtraction operation) can be easily repurposed to decode the exponent and shift the exponent.

But the quire logic (fixed point arithmetic) might use more area than a larger float-point. But maybe in power usage it pays of.

piadodjanho··on Floating Point Visually Explained (2017)
In practice, subnormal are very rarely used. Most compiler disable subnormals when compiling with anything other than -O0. It takes over a hundred cycle to complete an operation.

Demo: #include <stdio.h>

    int
    main ()
    {
    
        volatile float v;
        float acc = 0;
        float den = 1.40129846432e-45;
    
        for (size_t i; i < (1ul<<33); i++) {
            acc += den;
        }
    
        v = acc;
    
        return 0;
    }
With -01: $ gcc float.c -o float -O1 && time ./float ./float 8.93s user 0.00s system 99% cpu 8.933 total

With -O0: $ gcc float.c -o float -O1 && time ./float ./float 20.60s user 0.00s system 99% cpu 20.610 total

piadodjanho··on Floating Point Visually Explained (2017)
Also a great format to count how many representation are wasted with redundant representation (ZeroS, NaN, +inf, -inf).
piadodjanho··on Floating Point Visually Explained (2017)
Ackchyually...

The IEEE-754 has a lot of redundant representation. Not where you would expect though.

Caveat: Those features are invaluable for some niche applications, but not for the average joe.

To start. Every IEEE-754 float has two zero representation: one for positive zero and another negative negative zero (sic).

The special numbers are another source of redundancy. The the double format, have about 9,007,199,254,740,992 different combination to encode three different states that a production ready software shouldn't reach: NaN, +inf and -inf.

Other than the redundancy, the double have many rarely used combination. For instance, the subnormals representation. Unless you are compiling your program with -O0 or with some exotic compiler, they are disabled by default. One subnormal operation can take over a hundread of cycles to complete. Therefore, more 9,007,199,254,740,992 wasted combination.

If that wasn't bad enough, since the magnitude of the numbers follows a normal distribution (someone whose name I forgot's law), the most significant bits of the exponent field are very rarely used. The IEEE-754 encoding is suboptimal.

The posit floating point address all those issues. It uses an tapered encoding for the exponent field.

piadodjanho··on Vitamin D Insufficiency is Prevalent in Severe Covid-19
The Solar Zenith Angle is the most important. This is what changes from winter to summer and morning to night.

Vitamin D production is only made on the UVB range that is highest at midday. Both UVA and UVB causes erythema. Counterintuitively to common sense, it is better to sun bath midday than early in the morning.

If you sunbath at 8 you might need twice as many time to produce the same amount of vitamin D and you be exposed to much more UVA, thus more like to get burn.

piadodjanho··on Vitamin D Insufficiency is Prevalent in Severe Covid-19
I've read a few paper on this subject you are absolutely correct, I don't know why you are have been downvoted.

Vitamin D is only produced with in UVB wavelength [1]. No vitamin D is produced over 318nm. I wonder if that's the reason they divided the range in UVA, UVB and UVC.

The solar ray incidation angle, pollution and altitude (higher, more UVB) affects the amount of UVB that hits the surface [2].

Therefore, the time of the day you are sunbathing is important to optimize Vitamin D synthesis. Midday is the best time. If you live bellow 25 degree latitude, the UVA/UVB ratio on winter is about the same on summer. Of course, you should take in consideration the weather and the UV index. I'm talking only about the ratio.

This paper [3] has guideline for sun exposure for Australian. It is possible to correlate the data for other places in the same latitude -- taking in consideration the Australian differences in UV index.

[1] https://www.direct-ms.org/wp-content/uploads/2018/01/Vit-D-s... [2] https://www.researchgate.net/publication/285056396_Vitamin_D... [3] https://staging.mja.com.au/system/files/issues/194_07_040411...

piadodjanho··on Vitamin D Insufficiency is Prevalent in Severe Covid-19
Not for vitamin D production.

Vitamin D is produced on UVB spectrum [1 Fig. 1] that decreases with the solar azimuth degree [2].

[1] https://www.direct-ms.org/wp-content/uploads/2018/01/Vit-D-s...

[2] https://www.researchgate.net/publication/285056396_Vitamin_D...

piadodjanho··on Vitamin D Insufficiency is Prevalent in Severe Covid-19
Adding some information for those interested in more precise numbers.

This paper [1] has the recommended exposure time for a few cities in Australia. If you live in the same latitude, as long you live in the same latitude, this can be used as a guideline.

https://staging.mja.com.au/system/files/issues/194_07_040411...

piadodjanho··on Colab Pro
The page says its twice the traditional Cloud.
piadodjanho··on Learn X in Y minutes Where X=Prolog
Any suggestion on what Prolog to use?
piadodjanho··on Learn X in Y minutes Where X=Prolog
What are the differences from Prolog for a constraint programing language such MiniZinc?
piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
The supreme court judges already stated that Gleen Greenwald cannot be investigated because the reporting. The police got this conversation from a backup kept by the hackers. There is no chance this accusation will be accept by a judge, it goes against the constitution.

Some people speculate the prosecutor was looking for exposure and might run for some position in the next election.

piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
I should made it clearer that Gleen Greenwald that was not hacked.

I described the procedure the hackers used to access the politicians conversations. Not GG's.

In one interview, Gleen Greenwald said the computer with the copy of the data isn't connect to the internet. Many news organization worked with the same offline computer at his office. According to him, he did that to avoid leaking personal information.

Yet, he published conversation of others journalists with theirs sources. Violating the secrecy of the source (protect by law). I should note that this other site editorial line is the opposite of GG's.

GG suggested the hackers to delete all the files. They didn't. That's how the police manage to get the messages of GG talking with the hackers.

piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
Ironically, he Intercept published conversations from another news site with their source. They use the argument "the law protects the secret of the source", yet reveal others sources.
piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
The accusation [1] is public. I will translate the highlight parts of the conversation transcription between the hacker and Gleen Greenwald.

In another thread I discussed how they hacked the Telegram accounts.

Page 58:

> MOLIÇÃO: Like it happened with Danilo Gentilli, the MBL and Holiday. We got [their Telegram account] last october. They only started talking [on the news] about this [Telegram hacking] now.

Some context:

Danilo Gentilli is a liberal tv show host that was very vocal on the last election; MBL is acronym to "Free Brazil Movement"; Holiday is a politician with MBL affiliation.

In Brazil, the liberals are the right-wings. Their motto is "Liberal on the economy and conservative on the customs", custom as traditional practice.

On page 58:

> GG: Because, for instance, if they knew that someone is getting ready to publish [the hacked conversations], or worst, that we [The InterceptBR] are ready to publish, they would get an judicial order to forbid the publication or reporting of this material. But so far, no one have done that. Therefore, it look like they don't know who has "this material".

> GG: They know someone have this, but they don't know who has it.

> M: Yes. We also want to know your opinion about something... Once you publish the articles, everyone will exclude their conversations, everyone will exclude their Telegram. We want to know what do you suggest us should to do. We have some names separated, we can get [their conversation from Telegram] this weekend or leave it for a while. [I ask this]because, there are some people that already changed their number, we can't get their conversations anymore.

Page 60.

> GG [black text included]: Yes. Look, we are going to [??], what is going to happen? They are going for sure try to accuse us in participating in the hacking. They are going to accuse that us of being part on the hacking attempt. For sure, they are going to accuse us. So, I'll keep the messages for myself, the messages are the proof that you only talked to us after you already done everything. This is very important for us as journalist to show that our source only talked after they already had everything.

Page 61.

> GG [only text in red]: We already saved everything, we received everything. I think you had any reason to keep any of this, understood?

In the bold text, Molicao asks if they should hack more people, he wanted to know GG opnion.

Page 62.

> GG: Yes, yes. This is difficult because I can't give you advice but I've the obligation to protect my source and this obligation is a very serious obligation, very serious. We are going to do everything we can to do this, understood?

> GG [only red text]: Also, we are going to say we received everything before those articles from the other week about Moro [begin hacked], about the other hacking.

[1] https://politica.estadao.com.br/blogs/fausto-macedo/wp-conte...

piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
In case someone is wondering how they hacked Telegram.

They used caller id spoofing and a telco vulnerability.

1. Change your phone ID and try to login on Telegram;

2. Telegram will send an SMS with an authentication number followed by a phone call to the actual mobile phone;

3. To avoid the message going through, spams the victim with many VoIP calls;

4. The Telegram call will be recorded on the missed call voice messages;

In Brazil, you can listen to the recorded messages calling your own number. Surprisingly, the telco only checks if the calling number was equal to the called number.

5. Again, with the call id spoofing, call your own number.

6. Now you have access to the victim's Telegram (past conversations and contact list)

7. ???

8. Profit.

EDIT: I translated part of the transcription used to accuse GG in another thread.

piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
I just read the part of accusation that was used to indicted Gleen Greenwald. There is no proof of collusion with the hacker. Actually in his communication with the hackers, he was very cautious . Also, the Supreme court had decided GG couldn't be investigated when he start publishing the conversations.

> If someone hacked into your phone, and published it, it would be a crime. If they gave it to a journalist, not a crime?

The hacking is a crime, the publishing isn't. But once you start giving direction to the hacker, you became the hacker accomplice.

> If there is uncovering of actual, illegal activities, then it changes the dynamic, but what if it's not? What if the 'details' are just embarrassing, or problematic for those hacked? Do we want to legitimise theft for political objectives?

That's whats happened in Brazil. There published communication didn't show any _unquestionably_ illegal activity. Even if did, the brazillian law don't allow to use illegally obtained proofs (unless if absolves someone).

piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
This is not about the journalist knowing the information was obtained illegally. This is about the journalist asking the hacker to get information from people of interest.
piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
To be political prisoner you need to be in prison first.

This might be a political persecution, but saying he is a political prisoner is a bit of stretch.

It will take several years for his case to be appreciate by every last instance (in Brazil we have 3 instances). Even if he is found guilty, he won't be sentenced to jail.

piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
Is is legal for a journalist to ask for a hacker to get some private information about chosen politician in America? (Serious question).
piadodjanho··on Glenn Greenwald Charged with Cybercrimes in Brazil
David Miranda was elect as substitute to another congressman. I don't think he has the public support to be elect by himself.

He only became a congressman when the other politician abdicate the position due life threats.

Page 1 of 3Next →