Error Floating Point Division By Zero Delphi
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring runtime error floating point division by zero developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question floating point division by zero error message x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; error calendar vyp floating point division by zero it only takes a minute: Sign up Floating point division by zero exception in Delphi5 up vote 7 down vote favorite My app is written in Delphi5. I am using madExcept to track down bugs. I tracked down a "Floating
Floating Point Division By Zero Pdf
point dvision by zero" exception, where it shouldn't be. The code segment, where it is raised, goes as followed: val:=100*Power(1.25,c); where 'c' actually always has the value '1'. The stack trace of the log: main thread ($338f8): 00403504 +010 MyApp.exe System 1970 +5 @FRAC 00479148 +058 MyApp.exe Math Power 007ae8a6 +262 MyApp.exe MyClass 1962 +36 TMyClass.FormMouseWheel I had another exception at one point, where a division did take place, however the divisor was a variable, which also had the floating point division by zero txd workshop value '1' when the exception occured. That i was able to debug and reproduce. My question: what am i missing? Are there some false positives about floating point division that i am not aware of? Furthermore: I am not using any C++ DLLs at the exception points as they tend to handle FP divisions differently (returning NaN or +/-INF rather than raising an exception). Any pointers appreciated. delphi floating-point division delphi-5 divide-by-zero share|improve this question asked Nov 8 '11 at 8:10 simonescu 131110 3 Doesn't sound very plausible. I don't think your debugging tools are pointing you to the right place, or perhaps the variables aren't holding what you think they are. –David Heffernan Nov 8 '11 at 8:30 Don't remember if D5 already had it, but did you try to check what's happening in the CPU/FPU view when that code is executed? –user160694 Nov 8 '11 at 9:04 @ldsandon Of course D5 already allowed to use Alt-F2 and step into the CPU/FPU view. Good idea. But I guess an unhandled FPU exception will break in the System._Frac code. –Arnaud Bouchez Nov 8 '11 at 10:26 Are you using any external DLLs at all? If so, they might have changed the FPU control word. See this posting on some more info: wiert.wordpress.com/2009/05/06/… –Jeroen Wiert Pluimers Nov 8 '11 at 11:09 add a comment| 3 Answers 3 active oldest votes
handling of floating
Floating Point Division By Zero Recover My Files
point overflow and underflow, and invalid floating point operations such
Invalid Floating Point Operation Delphi
as division by zero. In the {$FINITEFLOAT ON} state, which is the default, the results of floating http://stackoverflow.com/questions/8047548/floating-point-division-by-zero-exception-in-delphi5 point calculations are checked, and an exception is raised when there is an overflow, underflow, or invalid operation. In the {$FINITEFLOAT OFF} state, such floating point calculations will return NAN, -INF, or +INF. Extra http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/compdirsfinitefloat_xml.html runtime processing is required to check the results of floating point calculations and raise exceptions. If your Delphi code uses floating point operations but does not require strict enforcement of overflow/underflow exceptions, you can turn {$FINITEFLOAT OFF} to get slightly faster runtime execution. Note: Delphi has traditionally provided strict floating point semantics. If you have Delphi code that relies on exceptions to be raised in overflow and underflow conditions, you should retain the default setting ({$FINITEFLOAT ON}). See Also Internal Data Formats Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved. What do you think about this topic? Send feedback!
of it will not work correctly without it enabled. Please turn JavaScript back on and reload this page. Please enter a title. You can not post a blank message. Please type your message and try again. More discussions in OpenCL Where is this place located?CommunityAll PlacesDevgurusOpenCL https://community.amd.com/thread/137997 4 Replies Latest reply on Aug 16, 2010 12:17 PM by danbartlett@ntlworld.com http://forum.lazarus.freepascal.org/index.php?topic=7675.0 Floating point division by zero error when building CL programs for CPU danbartlett@ntlworld.com Aug 13, 2010 11:07 AM Hi,When I try tobuild a CL program for my CPU (Intel Core i7 Q720) using Delphi, I get a "EZeroDivide" exception (Floating point division by zero). Thekernel code isjust a nonsense test floating point kernel, but it builds + runson the GPU ok. If I remove "sin" from the kernel, it compiles + runs ok, but I've also had problems with other kernels causing a divide by zero error when building.__kernel void some_func(__global float4 * inval, __global float * outval) { size_t gid = get_global_id(0); float g_size = (float)get_global_size(0); outval[gid] = sin((float)gid/g_size) * length(inval[gid]) + 17.0f; floating point division } 2540Views Tags: none (add) visionContent tagged with vision This content has been marked as final. Show 4 replies Floating point division by zero error when building CL programs for CPU genaganna Aug 13, 2010 11:23 AM (in response to danbartlett@ntlworld.com) Originally posted by: danbartlett@ntlworld.com Hi, When I try tobuild a CL program for my CPU (Intel Core i7 Q720) using Delphi, I get a "EZeroDivide" exception (Floating point division by zero). Thekernel code isjust a nonsense test kernel, but it builds + runson the GPU ok. If I remove "sin" from the kernel, it compiles + runs ok, but I've also had problems with other kernels causing a divide by zero error when building. Are you getting exception while running sample or while compiling kernel code?It looks like you are getting exception while running this code on CPU becasue CPU handles exception but GPU does not handle exceptions. Like Show 0 Likes(0) Actions Floating point division by zero error when building CL programs for CPU danbartlett@ntlworld.com Aug 13, 2010 11:28 AM (in response to genaganna) I get the error when building it
FAQ Wiki Bugtracker IRC channel Developer Blog Follow us on Twitter Latest SVN Mailing List Other languages Foundation Website Useful Wiki Links Project Roadmap Getting the Source Screenshots About donations (wiki) Bookstore Computer Math and Games in Pascal Lazarus, the complete guide (only a few left) Search Advanced search « previous next » Print Pages: [1] 2 Author Topic: divide by zero (Read 19308 times) mbohn Full Member Posts: 120 divide by zero « on: October 13, 2009, 11:54:02 pm » fpc 2.2.4Lazarus 0.9.27OSX 10.6.1After two full days of trying to figure out (without the help of a debugger) why my computationally-intensive Delphi app was blowing up I found that fpc doesn't catch a divide-by-zero error. If the offending calc is inside a try..except block the exception never gets raised. It will report +infinity as the result if you try to print out the results but this is less than useful, especially if your Delphi code has try..except blocks all over the place.I've seen some discussion on the forum and wiki but not enough to understand why this is set up that way and if it is considered a bug.Any insight or workarounds would be appreciated.Mark Logged Leledumbo Hero Member Posts: 7351 Programming + Glam Metal + Tae Kwon Do = Me Re: divide by zero « Reply #1 on: October 14, 2009, 12:06:36 pm » What's the type of of the expression? 1 div 0 (integer division) is indeed a EDivByZero exception, but 1 / 0 (floating point) is not. It leads to infinity as what you get. Logged Follow this if you want me to answer: http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3Fhttp://pascalgeek.blogspot.comhttps://bitbucket.org/leledumbohttps://github.com/leledumboCode first, think later - Natural programmer B) Bart Hero Member Posts: 2330 Re: divide by zero « Reply #2 on: October 14, 2009, 01:23:51 pm » AFAIK an integer div by zero should raise EDivByZero, whereas a floating point division by zero should raise EZeroDivideSee: http://docwiki.embarcadero.com/VCL/en/SysUtils.EZeroDivideQuoteSysUtils.EZeroDivide exception is raised when an application attempts to divide a floating-point value by zero. Note: Integer divide