Re: Bad comparison between double and uint64_t

2021-06-24 Thread Masato Asou
Hi Ali, From: Ali Farzanrad Date: Thu, 24 Jun 2021 07:25:24 + > Hi Masato, > > Masato Asou wrote: >> Hi Ali, >> >> In this case, ULLONG_MAX is implicitly cast to double, isn't it? > > Yes it is implicitly cast to double, but due to floating point number > precision, ULLONG_MAX will

Re: Bad comparison between double and uint64_t

2021-06-24 Thread Ali Farzanrad
Hi Masato, Masato Asou wrote: > Hi Ali, > > In this case, ULLONG_MAX is implicitly cast to double, isn't it? Yes it is implicitly cast to double, but due to floating point number precision, ULLONG_MAX will convert to (ULLONG_MAX + 1). So in case val is really ULLONG_MAX + 1, this condition is

Re: Bad comparison between double and uint64_t

2021-06-23 Thread Masato Asou
Hi Ali, In this case, ULLONG_MAX is implicitly cast to double, isn't it? Do you have any problems if you don't cast to double? -- ASOU Masato From: Ali Farzanrad Date: Wed, 23 Jun 2021 20:24:27 + > Oh, my bad, sorry. > I assumed that val is always integer. > I guess it is better to

Re: Bad comparison between double and uint64_t

2021-06-23 Thread Ali Farzanrad
Oh, my bad, sorry. I assumed that val is always integer. I guess it is better to ignore val == ULLONG_MAX: === RCS file: /cvs/src/sbin/disklabel/editor.c,v retrieving revision 1.368 diff -u -p -r1.368 editor.c --- editor.c

Bad comparison between double and uint64_t

2021-06-23 Thread Ali Farzanrad
Hi tech@, disklabel shows a warning at build time which might be important. Following diff will surpass the warning. === RCS file: /cvs/src/sbin/disklabel/editor.c,v retrieving revision 1.368 diff -u -p -r1.368 editor.c --- editor.c