From: james b. <bo...@ut...> - 2015-07-27 19:11:21
|
thanks everyone hope everyone who went enjoyed Prague would have loved to be there - but way too busy here. Jim > On Jul 22, 2015, at 3:56 PM, Dave Beeman <db...@Co...> wrote: > > Thanks to Hugo and Dieter for the explanations. Thet other thing to > keep in mind is that at the scripting level, all floating point variables > are 32 bit floats, not doubles. This can be a source of roundoff errors > and is the reason that some XODUS dialogs will report numbers like > "0.0000000237" or similar. At the C code level, most important > variables that are used in numerical solution (particularly those > involving time) have been converted to doubles. > On Wed, 22 Jul 2015, Cengiz Günay wrote: > >> Thanks, Hugo! That's quite clear. It's good to hear that you're still on the >> list. Thankfully my code did not actually contain this overflow error, it >> was something I was trying to verify the calculations. Is it safe to say >> that all floating point variables in Genesis are double precision? Do you >> know if this is also true for "extended fields" in generic objects created >> using addfield? >> -Cengiz >> On Wed, Jul 22, 2015 at 6:14 PM, Hugo Cornelis <hug...@gm...> >> wrote: >> Hi Cengiz, >> I quickly checked the behaviour of both commands with GDB, and here is >> what happens: >> The first result 0.5500000385 is correct, GDB reports >> 0.55000003851059043 as the double precisions result. >> For the behaviour of the second command: >> echo { 2012303744.1 / 3658733824 } >> What happens goes as follows: >> The second argument in the input, the integer 3658733824, is larger >> than the highest signed 32bit integer (which is 2147483647). >> GENESIS uses the sscanf() function to read the integer from the >> command line. This function does not generate an error when an >> overflow occurs and simply returns 2147483647, so GENESIS continues >> its operation with this result assuming everything is fine. >> So internally the command is treated as this command: >> echo { 2012303744.1 / 2147483647 } >> for which GDB returns: >> 0.93705195236813832 >> Obviously, this behaviour is totally undesired and GENESIS should emit >> an error message for the integer overflow, but does not. >> The work around is as you say, to suffix a .0 after the integer to >> force GENESIS to use floating point calculations. >> Hugo >> On Wed, Jul 22, 2015 at 10:48 PM, Cengiz Günay <cg...@em...> >> wrote: >> Hi, >> I have been pulling my hair trying to debug arithmetic >> inconsistencies in Genesis that are caused by large truncation >> errors from simplest calculations and inconsistent PI >> definitions, which I realize have been known and we need to be >> cautious about. However, I wanted to report something really >> disturbing: >> > echo { 2012303744.1 / 3658733824.0 } >> 0.5500000385 >> > echo { 2012303744.1 / 3658733824 } >> 0.9370519524 >> Does anyone have an explanation for this behavior? This can >> cause seriously wrong calculations and hidden bugs. >> I think the take home message is to always put a .0 behind >> integer numbers that are going to be in floating point >> calculations. :) >> Best, >> -Cengiz >> -- >> Cengiz Gunay >> Postdoctoral Fellow, Dept. of Biology >> Visiting Faculty, Dept. of Math & CS >> Emory University >> http://www.biology.emory.edu/research/Prinz/Cengiz/ >> --------------------------------------------------------------------------- >> --- >> _______________________________________________ >> Genesis-sim-users mailing list >> Gen...@li... >> https://lists.sourceforge.net/lists/listinfo/genesis-sim-users >> -- >> Hugo >> -- >> Hugo Cornelis, Ph.D. >> Agora Classica -- CTO >> http://www.agoraclassica.com/ >> GENESIS-3 -- lead architect >> http://www.genesis-sim.org/ > ------------------------------------------------------------------------------ > _______________________________________________ > Genesis-sim-users mailing list > Gen...@li... > https://lists.sourceforge.net/lists/listinfo/genesis-sim-users |