* frexp man page: FLT_RADIX vs. 2 @ 2024-01-03 1:29 Morten Welinder 2024-01-03 1:49 ` Alejandro Colomar 0 siblings, 1 reply; 5+ messages in thread From: Morten Welinder @ 2024-01-03 1:29 UTC (permalink / raw) To: alx; +Cc: linux-man A very minor bug: The main body of frexp's man page says the exponent returned is for a power of two. That agrees with, for example, the C99 standard as well as https://en.cppreference.com/w/cpp/numeric/math/frexp However, the sample program in the man page uses FLT_RADIX. The value of that macro need not be 2 so the man page should be changed to use 2 directly. M. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: frexp man page: FLT_RADIX vs. 2 2024-01-03 1:29 frexp man page: FLT_RADIX vs. 2 Morten Welinder @ 2024-01-03 1:49 ` Alejandro Colomar 2024-01-03 3:50 ` Matthew House 0 siblings, 1 reply; 5+ messages in thread From: Alejandro Colomar @ 2024-01-03 1:49 UTC (permalink / raw) To: Morten Welinder; +Cc: linux-man [-- Attachment #1: Type: text/plain, Size: 984 bytes --] Hello Morten, On Tue, Jan 02, 2024 at 08:29:08PM -0500, Morten Welinder wrote: > A very minor bug: > > The main body of frexp's man page says the exponent returned is for a > power of two. That agrees with, for example, the C99 standard as well > as https://en.cppreference.com/w/cpp/numeric/math/frexp > > However, the sample program in the man page uses FLT_RADIX. The value > of that macro need not be 2 so the man page should be changed to use 2 > directly. The value of that macro is defined to be 2; it can't have any other value. ISO C defines it in <http://port70.net/~nsz/c/c11/n1570.html#5.2.4.2.2p11>. POSIX defines it in <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/float.h.html>. Maybe the definition of frexp() by ISO C and POSIX should be changed to define it in terms of FLT_RADIX instead of 2. Have a lovely day, Alex -- <https://www.alejandro-colomar.es/> Looking for a remote C programming job at the moment. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: frexp man page: FLT_RADIX vs. 2 2024-01-03 1:49 ` Alejandro Colomar @ 2024-01-03 3:50 ` Matthew House 2024-01-03 3:57 ` Alejandro Colomar 0 siblings, 1 reply; 5+ messages in thread From: Matthew House @ 2024-01-03 3:50 UTC (permalink / raw) To: Alejandro Colomar; +Cc: Morten Welinder, linux-man On Tue, Jan 2, 2024 at 8:49 PM Alejandro Colomar <alx@kernel.org> wrote: > The value of that macro is defined to be 2; it can't have any other > value. > > ISO C defines it in > <http://port70.net/~nsz/c/c11/n1570.html#5.2.4.2.2p11>. > > POSIX defines it in > <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/float.h.html>. > > Maybe the definition of frexp() by ISO C and POSIX should be changed to > define it in terms of FLT_RADIX instead of 2. > > Have a lovely day, > Alex Every version of ISO C says (emphasis mine): The values given in the following list shall be replaced by constant expressions with implementation-defined values that are *greater or equal* in magnitude (absolute value) to those shown, with the same sign: -- radix of exponent representation, b FLT_RADIX 2 And POSIX defines it similarly. So FLT_RADIX can be greater than 2 (unless the implementation defines __STDC_IEC_559__), it just can't be any less. Indeed, the subsequent EXAMPLE 1 in ISO C sets FLT_RADIX to 16. Thus, since frexp(3) is defined to return a power of 2, interpreting it as a power of FLT_RADIX is incorrect in the general case. Thank you, Matthew House ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: frexp man page: FLT_RADIX vs. 2 2024-01-03 3:50 ` Matthew House @ 2024-01-03 3:57 ` Alejandro Colomar 2024-01-29 12:29 ` Alejandro Colomar 0 siblings, 1 reply; 5+ messages in thread From: Alejandro Colomar @ 2024-01-03 3:57 UTC (permalink / raw) To: Matthew House; +Cc: Morten Welinder, linux-man [-- Attachment #1: Type: text/plain, Size: 1744 bytes --] Hi Matthew, On Tue, Jan 02, 2024 at 10:50:51PM -0500, Matthew House wrote: > On Tue, Jan 2, 2024 at 8:49 PM Alejandro Colomar <alx@kernel.org> wrote: > > The value of that macro is defined to be 2; it can't have any other > > value. > > > > ISO C defines it in > > <http://port70.net/~nsz/c/c11/n1570.html#5.2.4.2.2p11>. > > > > POSIX defines it in > > <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/float.h.html>. > > > > Maybe the definition of frexp() by ISO C and POSIX should be changed to > > define it in terms of FLT_RADIX instead of 2. > > > > Have a lovely day, > > Alex > > Every version of ISO C says (emphasis mine): > > The values given in the following list shall be replaced by constant > expressions with implementation-defined values that are *greater or > equal* in magnitude (absolute value) to those shown, with the same sign: > > -- radix of exponent representation, b > > FLT_RADIX 2 > > And POSIX defines it similarly. So FLT_RADIX can be greater than 2 (unless > the implementation defines __STDC_IEC_559__), it just can't be any less. > Indeed, the subsequent EXAMPLE 1 in ISO C sets FLT_RADIX to 16. Oops, my bad. > > Thus, since frexp(3) is defined to return a power of 2, interpreting it as > a power of FLT_RADIX is incorrect in the general case. Hmm, then it's a bug in the manual page. The function is curiously defined in terms of 2 regardless of what FLT_RADIX is. I'll fix it tomorrow, unless anyone wants to send a patch for it before that. Thank you both! Alex > > Thank you, > Matthew House > -- <https://www.alejandro-colomar.es/> Looking for a remote C programming job at the moment. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: frexp man page: FLT_RADIX vs. 2 2024-01-03 3:57 ` Alejandro Colomar @ 2024-01-29 12:29 ` Alejandro Colomar 0 siblings, 0 replies; 5+ messages in thread From: Alejandro Colomar @ 2024-01-29 12:29 UTC (permalink / raw) To: Matthew House; +Cc: Morten Welinder, linux-man [-- Attachment #1: Type: text/plain, Size: 562 bytes --] Hi Morten, Matthew, On Wed, Jan 03, 2024 at 04:57:55AM +0100, Alejandro Colomar wrote: > Hmm, then it's a bug in the manual page. The function is curiously > defined in terms of 2 regardless of what FLT_RADIX is. I'll fix it > tomorrow, unless anyone wants to send a patch for it before that. Finally fixed: <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=2b0b48b0acb2a18a640123117f330f5cae8ccba0> Have a lovely day, Alex -- <https://www.alejandro-colomar.es/> Looking for a remote C programming job at the moment. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-29 12:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-01-03 1:29 frexp man page: FLT_RADIX vs. 2 Morten Welinder 2024-01-03 1:49 ` Alejandro Colomar 2024-01-03 3:50 ` Matthew House 2024-01-03 3:57 ` Alejandro Colomar 2024-01-29 12:29 ` Alejandro Colomar
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox