|
Quote: In some cases, their loop variable is an int; in others a short; in others a long.
Given a choice which is best?
Use a size_t, unless you have a specific reason that needs negative numbers. The reason is because the compiler can warn you if you are writing a loop that may never terminate (checking for <=0 zero, for example).
For fast execution reasons, use unsigned int or int as they are guaranteed to be the natural word size of the platform.
For space reasons using 8 bit and 16 bit integers make sense, but don't use 'short' or 'long' etc, they are not guaranteed to have any specific width. If you need a specific bit width use uint8_t/int8_t/int_least8_t/uint_least8_t and their 16, 32 and 64 counterparts.
Using 'short' and writing code that assumes it is 16-bit or using 'int' and writing code that operates on it as a 32 bit integer is guaranteed to break on some platform; those are latent bugs because overflows are undefined behaviour and the compiler is allowed to generate code that crashes when you overflow a signed integer type (yes, that's happened to me on at least one ARM platform when compiled with clang and -O3).
In general, avoid using bare int/short/long long/long because the compiler cannot warn you if you are writing bugs.
|
|
|
|
|
In the old days we had to worry about every byte of memory and every tick of the clock, but with modern computers, it goes without saying that memory and speed are rarely limiting, unless: you were looping objects or something large, or you were designing a real-time app like a missile-tracking system. Some coders opt for 'better performance' even when it actually makes no significant difference, simply because they can.
|
|
|
|
|
Stop being bullied by this Johnny-Come-Lately Event[^] !
🎉 🕰 🎉
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
At the snowmen's Christmas party, was it love at frost sight?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Or would it be a blue ball?
I'm not sure how many cookies it makes to be happy, but so far it's not 27.
JaxCoder.com
|
|
|
|
|
As long as waffles aren't involved ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I don’t know what that means. And I don’t want to.
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
A flaky comment. I heard they evacuated when something s-melt wrong.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
Unfortunately, things heated up on the dance floor.
|
|
|
|
|
Where I live, about 2 people in 10 wear a mask to protect themselves and others from the Covid virus. And the governor has made it mandatory to wear a mask.
Also I was watching a program on YouTube called the "Watched Walker", and maybe 1 person in 20 was wearing a mask in the Christmas shopping crowds. Is this how they developed a new strain there?
What is it like where you live? Also, do you intend to get the vaccination when it is available?
BTW: It Seems to me that British TV is far superior to American TV. I love Time Team, and Absolute History
Curiosity didn't kill the cat, but it made it very ill.
|
|
|
|
|
People around here don't get served in businesses if they aren't wearing masks, but a lot of people will wear them incorrectly, like not covering their nose, because ... i won't say it here but people are a problem. It's frustrating to me, but nothing like what you're talking about. People are just.. smdh.
We learned nothing from the 1918 H1N1 outbreak, that's for sure.
Real programmers use butterflies
|
|
|
|
|
Anything that has happened more than two generations away has to be learned again.
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
here - Netherlands - most people wear masks in shops, however
a. they do not wear the mask with the nose covered,
b. they do not keep any distance anymore. This morning in the local supermarket I was picking something from a lower shelf and the guy (seemed a schoolboy to me) who (tried) to fill in the higher shelves bended over me!!
Even since people are obliged to wear a mask you see that distance is not respected anymore!
(but maybe there are other countries where people behave better)
|
|
|
|
|
So 8 out of 10 people have figured out that masks do nothing to prevent the spread of a virus. Bottom line, don't cough or sneeze on other people (it's always been rude).
Multiple studies, including one in Denmark that was released Thanksgiving week, have now shown that masks have no statistical impact on the spread of any viral disease.
|
|
|
|
|
|
Hear! Hear!
Get me coffee and no one gets hurt!
|
|
|
|
|
82M cases of covid worldwide, 19M of those are US. I guess those 8 out of 10 have figured that facemasks aren't fashionable and don't care about anyone but themselves.
Not everyone covers their cough or sneezes.
I'm not sure how many cookies it makes to be happy, but so far it's not 27.
JaxCoder.com
|
|
|
|
|
Yep, the interweb is a wonderful thing - if you want to get you and your loved ones killed. There's always going to be someone, somewhere telling you exactly what you want to hear. I have not looked into the science, but surely, even if there is only a slim chance that a mask will protect yourself and others, it makes sense to wear it. Or you can just do what I do and stay in 24x7.
According to my wife, (who does have to go out - to work), there are still plenty of people by us, (Northants, UK), still not wearing masks. So it's not surprising that, later today, we are going to have Boris tell us that we are going to get more restrictions. I doubt it will make much difference though. People just don't seem to get it. Until we introduce a Tier 11, (with an 8pm curfew, and snipers on the rooftops), I don't think we are going to stop the spread! 
|
|
|
|
|
5teveH wrote: Until we introduce a Tier 11, (with an 8pm curfew, and snipers on the rooftops) You know, those snipers may take out a few . . . the rest of the morons will probably take that as a hint.
Net result is many lives saved whilst the carcass's of those "sacraficed for the greater good" are picked at by crows.
You may yet get my vote for some office.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
5teveH wrote: with an 8pm curfew
Because viri don't come out until after 8pm. Keep listening to that science 
|
|
|
|
|
F-ES Sitecore wrote: Because viri don't come out until after 8pm. Keep listening to that science You forgot to quote the "snipers" bit. I don't know about the curfew, but I'm pretty sure that snipers is scientifically proven!
To be honest, I don't give a sh!t about the science. I just take note of what's happening in the real world. And, here in the UK, we've had 50K+ new cases two days running and nearly 1000 deaths yesterday. Our hospitals are at capacity and the NHS staff are at breaking point. Clearly the measures currently in place aren't working - because people are not sticking to the rules. So the only way this is going, is up. More cases. More deaths. And more restrictions.
|
|
|
|
|
5teveH wrote: the measures currently in place aren't working - because people are not sticking to the rules
Or maybe they're not working because they just don't work and\or are simply not compatible with human life? Maybe repeatedly doing the same thing over and over while expecting different results is simply a sign of madness?
|
|
|
|
|
F-ES Sitecore wrote: Maybe repeatedly doing the same thing over and over while expecting different results is simply a sign of madness? And maybe its grim desperation and a lack of any alternative. You don't need to be a rocket scientist to understand that viruses spread when people congregate. And, yes, I understand that asking people to stop congregating, is contrary to normal human existence. But desperate times, require desperate measures.
And, BTW, lock-down in March did stop the spread, so I don't think repeating that and expecting the same result, is madness. It's already a proven effective option - albeit with significant social and financial consequences. But I'm sure the government would be more than happy to hear from anyone who can suggest a better option.....
|
|
|
|
|
5teveH wrote: And, BTW, lock-down in March did stop the spread,
So why is it still here? The November lockdown was so we wouldn't be locked down over Christmas and after November the lockdowns continued ever more harshly not just for Christmas but the whole of December and now with literally no end in sight. Who knows, keep locking us down, maybe one of them will work?
5teveH wrote: But I'm sure the government would be more than happy to hear from anyone who can suggest a better option.....
Are you sure? Really? When was the last time you heard the phrase "herd immunity"? The thing that has got humans through things way worse than something with a 99% survival rate.
|
|
|
|
|
I am happy to accept that we will have to agree to disagree on this, but I have to correct your interpretation of what I said. "stop the spread" does not mean "eradicate" and I was not suggesting lock-down would do that.
And I'm pretty sure that "herd immunity" would have been considered, but quickly discounted once the consequences were considered - i.e: millions seriously ill; 100,000s dead; and the complete overwhelming of the NHS. That doesn't seem like a 'policy' a Government is ever going to be brave enough to go with! So, it's not even an option, never mind a better option.
|
|
|
|