- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I feel like I'm missing something obvious but why would 'while (i-- > 0)' loop forever?
i = 1, i-- = 0 (which is a valid unsigned int) 0 > 0 --> False -> loops stops
Maybe you meant 'while (i-- >= 0)' ? (which would loop forever is i is unsigned)
Admin
Admin
Your argument about that straw man is a straw man argument.
Admin
Random guess, but why do you think that the conditional is trying to compare 0 to i, and not the result of i--?
Admin
So you think taking on abortion is an easy one to win? Good luck.
Admin
Because the -- in this case is postfix; which means that i is decremented AFTER the value of i is used in the expression.
i=1, 1 > 0 --> true i is then decremented
Admin
Admin
No, I'm just trolling you since you have no substance other than "because I said so."
Admin
Who do we punish?
Explain how your choice fits into your definition of justice.
Admin
And then on the next loop: i=0, 0 > 0 --> false i is then decremented, falling back to MAX_INT the loop then exits
Admin
Which is still the result of i--, which is different than the result of --i.
Although, after getting some more caffeine in my system and running a quick test, I am also very intrigued as to why that guy thinks that "while(i-- > 0) { ... }" would cause an infinite loop.
Admin
Because think of the children!
Admin
I suspect John Appleseed meant to type your correction. This will suffice..
unsigned i=UINT_MAX; while (i) printf("%u\n",i--) ; printf("%u\n",i);
..because.. while (i-- > 0) printf("%u\n",i+1) ; ..may not be as efficient but more importantly could fail at runtime. ie: wrong processor architecture could raise a hardware exception/NaN when zero tries to "roll back" to minus one. You won't see this in a modern <limits.h>.. #define UINT_MAX (-1)
More likely you'll see the unsigned definition written out in full or possibly.. #define UINT_MAX (INT_MAX * 2U + 1)
Admin
What was she wearing? Did she take proper precautions in the dark?
Admin
This is exactly why Saudi Arabia has law requiring male escorts for any woman in public. Not a bad system, now that I think about it.
Admin
(For the rest of you, don't worry. The C language guarantees wrap-around for unsigned ints. Though I'd really like to have one of Billy's integer NaNs ...)
Admin
Admin
I was about to give you a sarcastic answer, but nevermind - most likely you are from the US and never travelled out of the US, not even to Canada. All over Europe you and your employer would pay a contribution determined by law to the National Health System for universal healthcare and for the national Social Security services - unemployment benefits, pensions, etc. Depending on how well the country is ran, these services work better or worse and in some of them where needed employers that care about their employees would offer a separate private medical insurance. This private insurance doesn't necessarily offer you much better medical services, but will take you off the waiting list in the National Health System and give you extra care with the auxiliary services.
So, in these countries, when you get sick, unemployed or you will give birth, the state will pay you the benefits from these funds while you are on your leave. Your company should plan anyway so that anyone missing from a team shouldn't be a show stopper for a project so from this perspective maternity leave shouldn't be an issue. A women getting pregnant is no different the someone getting sick or missing work for some other reasons. Also, in most of these countries part of the so-called maternity leave can be allocated to either the man or the woman in the couple.
I'll give you the example of Portugal, not a particularly rich country.
My wife got pregnant, so since I had the private medical insurance offered by the company, I used it to have her monitored in a private clinic while she was pregnant. Since we were expecting the baby early (he was born in the 30th week of pregnancy), the doctor recommended us to have the birth done in the public hospital, since they were better prepared for unusual cases - a private hospital (we had that option too) would only invest in what brings some profit and extreme cases that require special training and equipment are not the case.
So when her water broke, we went to the public hospital, she had there a C-section and our son was born. Then, by law, I had the right to 1 month of paternity leave (mandatory), fully paid, of which the first two weeks are mandatory to be used immediately after birth - you cannot legally go back to work. Then I could have taken within the first 6 months an additional month of leave paid at 80% of my paycheck - but I opted out.
All this - medical care, paternity leave - was paid from these funds where I contribute every month. Sure, some people use them more than others, few never take advantage, but generally the system works decently well and it gives you a very good safety net for when you get sick or unemployed. Some people game the system, it differs from country to country, etc, etc, but you get the idea.
Also, there are 20 work days of paid vacations, mandatory by law - your company just takes that into account whenever they size their workforce and that's it and it sizes also the paychecks as such.
There's more to explain, but that's how it works basically - I know some folks in the US would call this socialism, others communism, I call it common sense - in the end it works better for the society as a whole.
And yes, I've been in the US and was able to compare.
Admin
You collected benefits while traveling to Europe?
Admin
I'm curious: which way would you rather see them code the starting value?
Admin
Admin
Wrong. UINT_MAX must be usable in the preprocessor, so there must not be a cast.
I don't understand why the headers always use 4294967295U instead of 0xffffffffU though.
The nasty one is INT_MIN, which (on a 32-bit system) cannot be written -2147483648, since the magnitude - overflows an int instead it's (-1 - INT_MAX)
Admin
I am from Europe, I was just commenting that the original poster had the view I have seen with many people that never go outside their country (not necessarily US) - that the whole world must be functioning more or less like their own country.
So, this gentleman asked why the company should pay for the maternity leave and I explained that the system is such that the state pays for it, not the company.
Admin
Just out of curiosity, what would be wrong with a simple "(unsigned int)~0"?
Admin
Admin
Admin
Admin
Admin
Maybe this is a good time to comment on the famous article "Linux Developer Gets Laid". You all thought it was fake, it couldn't really happen. But it did. To prove it, I tried to take a photo of one of co-workers when she was 9 months pregnant, but the Linux screen behind her didn't show up well in the photo.
Admin
Admin
Just because she was pregnant, doesn't mean she got laid. She could have just borrowed a turkey baster and bought some sperm off of craigslist.
Admin
Admin
Two's complement system: x == -1, cast to unsigned wraps around, all is fine.
One's complement system: x == 0, cast yields 0!
Sign-magnitude system: x == -INT_MAX. Cast wraps to UINT_MAX+1-INT_MAX.
No really, that's how it works. The C language actually supports those kinds of systems, though it may be a bit hard to actually find one of the latter two.
OTOH, ~(unsigned int)0 is safe because the complement operates on an unsigned int.
Admin
See "Programming Hacks" (HAKMEM) item #154 (Gosper) for more insight into the problem with this kind of assumption.
Actually, the only valid, universal method is the UINT_MAX constant. Assuming there is one.
Admin
fixed
Admin
Besides, the standard intentionally allows most integer types to have more holes than a void megaminx. [image]
The standard also intentionally ruled out decimal because Knuth's style mixed them up too much.
Admin
...like, the best candidates?
Admin
Wait, so they bring the baby with them to work then? Or is breast-feeding not practiced in the US?
Admin
Using while (i-- > 0) is a WTF all of its own. One of the first rules of programming is that if you know exactly how many iterations to make, you use a for loop.
for (unsigned int i := MAXINT; i > 0; i--) {
}
... or whatever the specific syntax would be for an unsigned int and a for loop in c (I'd look it up if I could be bothered -- I'm not a c-man.
Admin
It is up to the employer to make the option of returning to work a more attractive option than staying at home to mind the baby. It is a person's choice whether to take up the option of returning to work or not. The employer has various ways of doing this, for example: a) ensuring that the work is enjoyable, b) ensuring that the remuneration is adequate, and c) offering the employee a flexible approach to their career.
It's really no different for a man or a woman, pregnancy or otherwise. If you want to keep any employee you need to ensure that staying in their employment is more attractive than not. Any possible hint of coercion to remain in such employment (in any form) is unacceptable. Increasing the person's remuneration is a totally acceptable technique for retaining your staff, and is also (if you think about it, it's pretty damn obvious) a far less expensive option than continually having to recruit replacements.
Admin
Standard operating procedure. This happens for all sorts of new employees, not just women getting pregnant. More than once I've sat there waiting for my new starter to arrive at the office, only to be told (usually sometime after lunch) that the person has changed their mind and won't be taking the job after all. You shrug, stroll on, refer this fact to the employment agency you got them from, suggesting that they add it to their database and that of all the other employment agencies they are in touch with, then get on the phone to the person at the top of the list of those you passed over for the no-show (and so on down until you either get someone you want or you run out of suitables).
This is why it is always a good idea, in any rejection letter, to suggest that they may still be in contention for some position in the company.
If it upsets the ego of the second-on-the-list person, then they are welcome to reject out of hand that offer, and quite frankly, I can do without such a drama-queen working for me in the first place.
Admin
An enlightened company would allow them to breast-feed directly within the business building, as part of the free creche facilities that will be laid on by the employer.
Admin
Another big lie.
I am paying for my own social security. It comes out of the money that was taken from my pay packet during the years I work.
Unfortunately, this fact is obscured by the people whose interest it is to devalue and/or discredit the welfare state, and to drive a wedge between generations: "I don't see why I should have to pay for the retirement of people who were too selfish to have children, whose sole purpose in life is to care for the bodily needs of their parents who lacked the good grace to kick the bucket after they became useless burdens on society."
Admin
Winner!
Admin
That's OK if you're a big corporation with thousands of employees. What if you're a company with a dozen employees?
Admin
TWTF...
The string of misogynistic, backwards thinking, stuck in the 50's idiots in comments here.
Perhaps they all forgot, or never knew, that the Information Technology industry was started by women, and for a while, programming was considered to be "Women's Work".
If men could get pregnant too, you bet no one would question maternity leave.
Admin
Then you're appropriately accommodating to your female employees so that they are sufficiently comfortable in their position that they prefer to come to work than quite their job (for example, offering a stay-at-home package or subsidising their third-party childcare). If you fail to provide that level of courtesy, or you choose not to outlay the few thousand a year that this will cost you, then you should not be running a business in the first place.
If the profit margin on your employees is so tight that a few thousand a year is the difference between profit and loss, your business is in trouble and you're better off without that person (and in fact should never have employed them in the first place).
Admin
You must be thinking handling utf-8 variable-width characters, which is a nightmare! utf-16 is fixed-with.
Admin
Admin
I'm sure it is, but one doesn't tend to get kicked in the balls for hour after hour, it tends to be a one off event.
Or at least, it is for me, you might get your kicks in a different way.