Liste des Groupes | Revenir à cl c |
DFS <nospam@dfs.com> writes:No it's not.On 6/12/2024 5:30 PM, Barry Schwarz wrote:On Wed, 12 Jun 2024 16:47:23 -0400, DFS <nospam@dfs.com> wrote:
>Wrote a C program to mimic the stats shown on:
>
https://www.calculatorsoup.com/calculators/statistics/descriptivestatistics.php
>
My code compiles and works fine - every stat matches - except for one
anomaly: when using a dataset of consecutive numbers 1 to N, all values40 are flagged as outliers. Up to 40, no problem. Random numbersdataset of any size: no problem.
>
And values 41+ definitely don't meet the conditions for outliers (using
the IQR * 1.5 rule).
>
Very strange.
>
Edit: I just noticed I didn't initialize a char:
before: char outliers[100];
after : char outliers[100] = "";
>
And the problem went away. Reset it to before and problem came back.
>
Makes no sense. What could cause the program to go FUBAR at data point
41+ only when the dataset is consecutive numbers?He has nothing to be embarrassed about. What he wrote is correct.>Also, why doesn't gcc just do you a solid and initialize to "" for you?Makes perfect sense. The first rule of undefined behavior is
"Whatever happens is exactly correct." You are not entitled to any
expectations and none of the behavior (or perhaps all of the behavior)
can be called unexpected.
I HATE bogus answers like this.
>
Aren't you embarrassed to say things like that?
The C standard's definition of "undefined behavior" is "behavior, uponThanks for feeling my pain!
use of a nonportable or erroneous program construct or of erroneous
data, for which this International Standard imposes no requirements".
If you don't like the way C deals with undefined behavior, that's
perfectly valid, and a lot of people are likely to agree with you.
But I advise against lashing out at people who are correctly explainingThe C standard really says "Whatever happens is exactly correct."?
what the C standard says.
DFS, since you've been posting in comp.lang.c for at least ten years,Time flies.
I'm surprised you're having difficulties with this.I'm surprised at some of the wonkiness of gcc and C.
Les messages affichés proviennent d'usenet.