jostapo 0 Posted March 31, 2003 Try the following code snippet: _blah = sin 180 player globalchat format["SIN180 is: %1",_blah] It should be 0 but is returning -8.74. Â If you run: _blah = sin 180.1 player globalchat format["SIN180 is: %1",_blah] It returns the correct answer just off 0. This is running 1.91 of the beta patch. Â Can anyone at bis shed a little light on this? Â Many of the functions and scripts CoC is currently using use cardinal compass headings, and these results are a little alarming. Thanks, Jostapo, aka Joel I should add that both SIN and COS both misbehave on cardinal compass headings. SIN being correct for 90 and 270, and COS being correct for 0 and 180. Share this post Link to post Share on other sites
suma 8 Posted March 31, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (jostapo @ Mar. 31 2003,08:19)</td></tr><tr><td id="QUOTE">_blah = sin 180 player globalchat format["SIN180 is: %1",_blah] It should be 0 but is returning -8.74.<span id='postcolor'> I tried this: player globalchat format["SIN180 is: %1",sin 180] The result was: -8.74228e-008 Which I think is acceptable error, caused probably by numeric errors, esp. when converting from degrees to radians. Share this post Link to post Share on other sites
toadlife 3 Posted March 31, 2003 It's not returning -8. It's returning some number so close to zero, that OFP's engine can't display it properly. I think that's why it's returning that strange string --> -8.74428e-008 -0.00000000874428 <---EDIT This is the number it's really returning. Try this and you'll see: hint format["%1",(sin 180) - 1] This code will also give you the same result (-1) hint format["%1",(-0.00000000874428 - 1)] Share this post Link to post Share on other sites
jostapo 0 Posted March 31, 2003 Sorry. Â I've been up all night tinkering on MLRS special effects and Cruise missile guidance scripts... and stumbled over that problem in some debug lines I had. It freaked me out for a minute as I thought we'd have to revisit a lot of code. Just goes to show you that all night coding sessions can lead to little ASSumptions. Thanks and sorry for wasting your time guys. Share this post Link to post Share on other sites
suma 8 Posted March 31, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (toadlife @ Mar. 31 2003,08:51)</td></tr><tr><td id="QUOTE">It's not returning -8. It's returning some number so close to zero, that OFP's engine can't display it properly. I think that's why it's returning that strange string --> -8.74428e-008 -0.00000000874428 Â <---EDIT This is the number it's really returning.<span id='postcolor'> What strange thing? -8.74428e-008 is no strange thing. I hope you did not intend to start a flame war on this poor number . -8.74428e-008 Â is normal real number in "scientific" notation used commonly in computers and even calculators. It can be read as -8.74428 * 10^-8, i.e. -8.74428 * 0.00000001. Share this post Link to post Share on other sites
toadlife 3 Posted March 31, 2003 Thanks for the info. After posting, I went an looked for "e-008" on the net and eventually found out what "e-008" meant, in of all places, Microsoft's MSDN website. They had a section on Numeric Format Strings. http://msdn.microsoft.com/library....ngs.asp Share this post Link to post Share on other sites
jostapo 0 Posted March 31, 2003 I used to develop exlusively in VC++ and should have remembered the string formatting. Lately all I've been working in is Delphi, VB, or .net stuff... and each of those languages has a way of 'dumbing down' the floating point displays. I thought the - was a seperator! I promise to flog myself duly. Share this post Link to post Share on other sites
bn880 5 Posted March 31, 2003 LMAO... this was a fun read. Share this post Link to post Share on other sites
dinger 1 Posted March 31, 2003 well, the supersmall number has the advantage that cos/sin functions don't give a divide by zero error. Share this post Link to post Share on other sites
jostapo 0 Posted March 31, 2003 So much for my CoC mates being supporting. Bn880 sucks! (kidding) Share this post Link to post Share on other sites
bn880 5 Posted March 31, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (jostapo @ Mar. 31 2003,17:22)</td></tr><tr><td id="QUOTE">So much for my CoC mates being supporting. Bn880 sucks! (kidding)<span id='postcolor'> Don't you mean supportive? lol j/k Share this post Link to post Share on other sites
walker 0 Posted March 31, 2003 Hi all Jostapo april fooled him self Mu Ha The best bit was he advertised his error in the developers forum Kind Regards to you Joel assumptions huh. PS by the way the problem with our forum is the backups our ISP made to protect our data when the upgraded the DB a couple of hundred of them! In Each table! Share this post Link to post Share on other sites