Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #447
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!panix!not-for-mail |
|---|---|
| From | Grant Edwards <invalid@invalid.invalid> |
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: cast double to short problem |
| Date | Wed, 7 Mar 2012 00:30:52 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 28 |
| Message-ID | <jj6a7s$l7k$1@reader1.panix.com> (permalink) |
| References | <jj64g2$fb8$1@dont-email.me> <jj6650$fa0$1@reader1.panix.com> <jj6714$tbh$1@dont-email.me> |
| NNTP-Posting-Host | c-24-118-110-103.hsd1.mn.comcast.net |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Transfer-Encoding | 7bit |
| X-Trace | reader1.panix.com 1331080252 21748 24.118.110.103 (7 Mar 2012 00:30:52 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Wed, 7 Mar 2012 00:30:52 +0000 (UTC) |
| User-Agent | slrn/0.9.9p1 (Linux) |
| Xref | csiph.com comp.os.linux.development.apps:447 |
Show key headers only | View raw
On 2012-03-06, Bill M <wpmccormick@just_about_everywhere.com> wrote: >> What exactly are you trying to accomplish with the above code? > > I need to interface to another system that does not accept floating > point values. It's interface specifies that certain values are X 10. > other are X 100. > Sounds like maybe what I need is a intermediate round operation? What you were doing was truncating (2.999999999999999 -> 2), and I suspect you want is indeed rounding to the nearest integer FP value followed by the conversion to integer: 2.999999999999999 -> 3.0000000000000 -> 3 $ man round #include <math.h> i = (short) round(MyDoubleValue * 100.0);
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Next in thread | Find similar
cast double to short problem Bill M <wpmccormick@just_about_everywhere.com> - 2012-03-06 16:52 -0600
Re: cast double to short problem Grant Edwards <invalid@invalid.invalid> - 2012-03-06 23:21 +0000
Re: cast double to short problem Bill M <wpmccormick@just_about_everywhere.com> - 2012-03-06 17:36 -0600
Re: cast double to short problem Grant Edwards <invalid@invalid.invalid> - 2012-03-07 00:30 +0000
Re: cast double to short problem Noob <root@127.0.0.1> - 2012-03-07 11:17 +0100
Re: cast double to short problem Grant Edwards <invalid@invalid.invalid> - 2012-03-07 15:23 +0000
Re: cast double to short problem "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2012-03-07 19:33 +0100
Re: cast double to short problem Grant Edwards <invalid@invalid.invalid> - 2012-03-07 20:13 +0000
Re: cast double to short problem Bill M <wpmccormick@just_about_everywhere.com> - 2012-03-08 11:45 -0600
csiph-web