Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Decomposing a FLOAT |
| Date | 2012-06-03 08:51 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <jqfmkv$804$1@dont-email.me> (permalink) |
| References | (3 earlier) <daa8e22c-1348-4bdc-b986-e5228c269efd@googlegroups.com> <jqd7s9$deh$1@dont-email.me> <pan.2012.06.02.19.41.09.107000@nowhere.com> <lnr4txfkhq.fsf@nuthaus.mib.org> <jqf676$9da$1@speranza.aioe.org> |
On 06/03/2012 04:11 AM, Raj Pashwar wrote: > On Sat, 02 Jun 2012 14:54:09 -0700, Keith Thompson wrote: > >> Nobody <nobody@nowhere.com> writes: >>> On Sat, 02 Jun 2012 10:27:20 -0400, James Kuyper wrote: >>>> I doubt it was a typedef, I think it was just a failure to be >>>> adequately aware of C's case-sensitivity. >>> >>> Or maybe it's just a case of conventional usage of capitals as a form >>> of emphasis (you can't use boldface in plain text and using HTML on >>> usenet is frowned upon). In much the same way that posters often use >>> quotes without necessarily meaning a C string literal. >> >> Whatever the OP meant, I hope he understands by now that referring to >> the type "float" as "FLOAT" is not a good idea. > > Yes, thanks :-) > > In fact John Kupyer was right : on my system FLOAT is a type-def for long > double. John's my brother, and we both spell it Kuyper, not Kupyer. No offense taken, but a programmer needs to be a bit more careful about details like that, or the programs won't work. There will, of course, per tradition, be at least one spelling error in this message, even though I didn't put one in deliberately. :-} The example code I provided was based upon the assumption that FLOAT meant float; that's a perfectly natural assumption, which is why it's a bad idea to define a typedef with that name; a more neutral name such as FP_TYPE would be better; a name that indicated the domain of applicability of the typedef would be even better. For example, one of third-party libraries I use chose PGS as it's identifying prefix, and PGSt_integer is their typedef for the integer type to be used when interfacing with their library. Since FLOAT was a typedef for long double, the example code I provided needs modification as follows: 1. Replace float with FLOAT 2. Remove the F suffixes on floating point constants. 3. Replace FLT prefixes on macros from the standard library with LDBL. 4. Replace INFINITY inside decompose_FLOAT() with x/sign. 5a. Replace f suffixes on standard math library functions with l. or 5b. #include <tgmath.h> and remove the f suffixes from the standard math library functions. Note: if there's any chance that FLOAT might be a typedef for a different type in the future, or on some other platform where this code needs to work, 4b is to be preferred to 4a. Item 3 needs to be changed accordingly; but that is relevant only in the test driver. -- James Kuyper
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Decomposing a FLOAT Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2012-05-31 20:59 +0000
Re: Decomposing a FLOAT "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> - 2012-05-31 21:44 +0000
Re: Decomposing a FLOAT Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-05-31 22:59 +0100
Re: Decomposing a FLOAT Ike Naar <ike@iceland.freeshell.org> - 2012-05-31 22:04 +0000
Re: Decomposing a FLOAT James Kuyper <jameskuyper@verizon.net> - 2012-05-31 18:57 -0400
Re: Decomposing a FLOAT jgk@panix.com (Joe keane) - 2012-06-01 23:02 +0000
Re: Decomposing a FLOAT Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-01 16:17 -0700
Re: Decomposing a FLOAT James Kuyper <jameskuyper@verizon.net> - 2012-06-02 10:27 -0400
Re: Decomposing a FLOAT Nobody <nobody@nowhere.com> - 2012-06-02 20:41 +0100
Re: Decomposing a FLOAT Keith Thompson <kst-u@mib.org> - 2012-06-02 14:54 -0700
Re: Decomposing a FLOAT Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2012-06-03 08:11 +0000
Re: Decomposing a FLOAT Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-03 08:33 -0400
Re: Decomposing a FLOAT Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2012-06-03 22:06 +0000
Re: Decomposing a FLOAT Ian Collins <ian-news@hotmail.com> - 2012-06-04 10:28 +1200
Re: Decomposing a FLOAT Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-03 19:46 -0400
Re: Decomposing a FLOAT James Kuyper <jameskuyper@verizon.net> - 2012-06-03 08:51 -0400
Re: Decomposing a FLOAT Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-03 07:48 -0700
Re: Decomposing a FLOAT James Kuyper <jameskuyper@verizon.net> - 2012-06-03 16:17 -0400
Re: Decomposing a FLOAT Keith Thompson <kst-u@mib.org> - 2012-06-03 13:43 -0700
Re: Decomposing a FLOAT Raj Pashwar <raj121190@hotmail.NOSPAM.com> - 2012-06-03 22:06 +0000
Re: Decomposing a FLOAT Ian Collins <ian-news@hotmail.com> - 2012-06-04 10:30 +1200
Re: Decomposing a FLOAT James Kuyper <jameskuyper@verizon.net> - 2012-06-03 21:12 -0400
Re: Decomposing a FLOAT Keith Thompson <kst-u@mib.org> - 2012-06-04 12:20 -0700
Re: Decomposing a FLOAT Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-06-05 03:54 -0700
Re: Decomposing a FLOAT James Kuyper <jameskuyper@verizon.net> - 2012-06-05 08:11 -0400
Re: Decomposing a FLOAT gazelle@shell.xmission.com (Kenny McCormack) - 2012-06-02 00:03 +0000
Re: Decomposing a FLOAT jgk@panix.com (Joe keane) - 2012-06-02 00:38 +0000
csiph-web