Sujet : Re: "undefined behavior"?
De : ike (at) *nospam* sdf.org (Ike Naar)
Groupes : comp.lang.cDate : 13. Jun 2024, 08:25:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrnv6l7o6.bn3.ike@iceland.freeshell.org>
References : 1 2 3
User-Agent : slrn/1.0.3 (Patched for libcanlock3) (NetBSD)
On 2024-06-12, DFS <
nospam@dfs.com> wrote:
//no outliers
if ( min > lo && max < hi) {
The condition for 'no outliers' is not the complement of
the condition for 'at least one outlier' below.
strcat(outliers,"none (using IQR * 1.5 rule)");
}
>
//at least one outlier
if ( min < lo || max > hi) {
for(i = 0; i < N; i++) {
double val = (double)nums[i];
if(val < lo || val > hi) {
sprintf(temp,"%.0f ",val);
temp[strlen(temp)] = '\0';
This is unnecessary;
sprintf terminates the generated string with a null character.
strcat(outliers,temp);
}
}
strcat(outliers," (using IQR * 1.5 rule)");
}