RE: [SDK]Double to long in c++ ?
| Date : Thu, 7 Jun 2007 16:03:38 -0400 |
| To : <XSI(at)Softimage.COM> |
| From : "Mathieu Leclaire" <mleclair(at)hybride.com> |
| Subject : RE: [SDK]Double to long in c++ ? |
|
Yeah, you are right. But you could still use the round function but
adding 0.25 or 0.5 and then casting it to a long will give similar results depending
if you want to go in fields or not (as explained by Luc-Eric) so that works
too. -----Original
Message----- no,
spaces are not significant in c++. From:
owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Mathieu Leclaire Wow, my emails really don’t
seam to pass through. I’ve been trying to send this reply since yesterday. Let
me try one more time… Here’s what I believe is happening: You have a space between (long) and t. So I believe doing long id =
(long) t * 3 * nbPoints; is the equivalent of doing long id = (long)(t * 3
* nbPoints); I think this way it converts the result of the entire equation so
if t = 1.99, then you get something like 23.88 and then cast it to a long so it'll
only keep the 23. But if you remove the space it’ll do the equivalent of long
id = (long)(t) * 3 * nbPoints; but if you have 1.99 and cast it to a long,
it'll only keep the value 1 which will screw up the result even more. So you
can use round(t) and that'll convert a 1.5 to a 2 and a 1.49 to 1. But I still find it weird that when you log it, it only shows the
value 2 even if the real value would be 1.99. But try those and let me
know if it helps. I think round is in Math.h so you might need to include that
library. |
- References:
- RE: [SDK]Double to long in c++ ?
- From: "Luc-Eric Rousseau" <lucer(at)Softimage.COM>
- RE: [SDK]Double to long in c++ ?
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: Re: JP_Separate.js anyone?
- Next by Date: Re: JP_Separate.js anyone?
- Previous by Thread: Re: JP_Separate.js anyone?
- Next by Thread: Re: JP_Separate.js anyone?
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |