Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "Fred J. Tydeman" <tydeman.consulting@sbcglobal.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Cast from double to int64_t/uint64_t : +/- inf handling ? |
| Date | 2012-04-26 14:49 +0000 |
| Organization | Tydeman Consulting |
| Message-ID | <Jd11RFbi8Eoq-pn2-FTNb1YretdeN@localhost> (permalink) |
| References | <jn911j$2cq$1@news.httrack.net> |
On Wed, 25 Apr 2012 14:17:23 UTC, Xavier Roche <xroche@free.fr.NOSPAM.invalid> wrote: > Are there any rules regarding cast result from double to > int64_t/uint64_t for positive/negative infinity, or is the result > totally undefined ? If Annex F is being followed, the requirements are: F.4 Floating to integer conversion If the integer type is _Bool, 6.3.1.2 applies and no floating-point exceptions are raised (even for NaN). Otherwise, if the floating value is infinite or NaN or if the integral part of the floating value exceeds the range of the integer type, then the ''invalid'' floating- point exception is raised and the resulting value is unspecified. Otherwise, the resulting value is determined by 6.3.1.4. Conversion of an integral floating value that does not exceed the range of the integer type raises no floating-point exceptions; whether conversion of a non-integral floating value raises the ''inexact'' floating-point exception is unspecified.360) The public test case: http://www.tybor.com/tflt2int.c shows how bad compilers do for that kind of conversion. --- Fred J. Tydeman Tydeman Consulting tydeman@tybor.com Testing, numerics, programming +1 (775) 358-9748 Vice-chair of PL22.11 (ANSI "C") Sample C99+FPCE tests: http://www.tybor.com Savers sleep well, investors eat well, spenders work forever.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
Cast from double to int64_t/uint64_t : +/- inf handling ? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-04-25 16:17 +0200
Re: Cast from double to int64_t/uint64_t : +/- inf handling ? James Kuyper <jameskuyper@verizon.net> - 2012-04-25 11:37 -0400
Re: Cast from double to int64_t/uint64_t : +/- inf handling ? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-04-26 10:54 +0200
Re: Cast from double to int64_t/uint64_t : +/- inf handling ? "christian.bau" <christian.bau@cbau.wanadoo.co.uk> - 2012-04-26 06:09 -0700
Re: Cast from double to int64_t/uint64_t : +/- inf handling ? Tim Rentsch <txr@alumni.caltech.edu> - 2012-05-07 16:46 -0700
Re: Cast from double to int64_t/uint64_t : +/- inf handling ? "Fred J. Tydeman" <tydeman.consulting@sbcglobal.net> - 2012-04-26 14:49 +0000
csiph-web