From dea5fd49e43d456151b5fed90a0759d2746c0912 Mon Sep 17 00:00:00 2001 From: kalwalt Date: Tue, 6 Oct 2026 16:35:57 +0200 Subject: [PATCH] fix(ar2): compute the random template index in double precision (#40) RAND_MAX + 1.0F converted 2147483647 to float (-Wimplicit-const-int-float-conversion). A double holds RAND_MAX + 1 exactly, and j * rand() no longer loses precision. k stays in [0, j-1]. Co-Authored-By: Claude Opus 5.5 --- lib/SRC/AR2/selectTemplate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/SRC/AR2/selectTemplate.c b/lib/SRC/AR2/selectTemplate.c index 661a052..fb2c10e 100644 --- a/lib/SRC/AR2/selectTemplate.c +++ b/lib/SRC/AR2/selectTemplate.c @@ -276,7 +276,7 @@ int ar2SelectTemplate( AR2TemplateCandidateT *candidate, AR2TemplateCandidateT * } if( j == 0 ) return -1; - k = (int)((float )j * rand() / (RAND_MAX + 1.0F)); + k = (int)((double)j * rand() / ((double)RAND_MAX + 1.0)); for( i = j = 0; candidate[i].flag != -1; i++ ) { if( candidate[i].flag != 0 ) continue; if( j == k ) {