Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-03

Why Ln(0) and 1/0 does not trigger Exception?

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sven Barth
to Xiangrong Fang: As title. My question is not just "it is a language construct", but "WHY". What's the…
Xiangrong Fang wrote
As title. My question is not just "it is a language construct", but "WHY". What's the benefit of doing so?

I already wrote this in the other thread: if you write "ln(0)" then the compiler will hardcode this as "NaN". I don't know what will happen with "ln(x)" with "x := 0" though. Maybe you'll need to set the exception mask correctly (see here:
http://www.freepascal.org/docs-html/rtl/math/setexceptionmask.html ) to get an exception.

Regards,
Sven

Reply by email

Xiangrong Fang
to Sven Barth

X := 0; Ln(X) seems to generated an exception without need to adjust exception mask. The reason I ask is that I get a strange crash while doing my charting program, I just suspected the reason being an exception is slipped through without being caught.

As this happened outside of IDE, I don't know the exact reason. I will do a screenshot and ask again.

Thanks.

2013/3/5 Sven Barth

Show quoted text 21 lines
Am 04.03.2013 16:05, schrieb Xiangrong Fang: As title. My question is not just "it is a language construct", but > "WHY". What's the benefit of doing so? > I already wrote this in the other thread: if you write "ln(0)" then the compiler will hardcode this as "NaN". I don't know what will happen with "ln(x)" with "x := 0" though. Maybe you'll need to set the exception mask correctly (see here: http://www.freepascal.org/**docs-html/rtl/math/** setexceptionmask.html<http://www.freepascal.org/docs-html/rtl/math/setexceptionmask.html>) to get an exception. Regards, Sven -- ______________________________**_________________ Lazarus mailing list .**freepascal.org http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130305/ccf223a6/attachment.html>

Reply by email