Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complex infinity/nan field values #8267

vicuna opened this Issue Sep 5, 2003 · 1 comment


None yet
1 participant
Copy link

vicuna commented Sep 5, 2003

Original bug ID: 1817
Reporter: administrator
Status: acknowledged
Resolution: open
Priority: normal
Severity: feature
Category: standard library
Tags: patch
Related to: #4748
Monitored by: @Chris00

Bug description

Full_Name: william margolis
Version: 3.06
OS: linux (suse 8.1)
Submission from: (

I love the Complex module, BUT:

   Objective Caml version 3.06

# 1/0;;
Exception: Division_by_zero.
# 1.0/.0.;;
-: float = inf.
# Complex.div;;
-:: Complex.t = { = nan; = nan.}

I understand why this is occuring, according to the standard sequencing through
the complex division algorithm. But, for people working on the Rieman sphere,
it would be very, very pleasant if 1/0 could register as, say { = infinity; = 0.} or something similar !?

This would certainly please extended-complex-plane people. (We expect a/0 = an
infinity type, not an nan...)

In any case, my desire is that I may be able to distinguish in the complex case
between nan and infinity cases, without having to create, say:

type sphere = INF | C of float * float ;;

and do all the argument matching comparisons each time.

Is there an easy/efficient implementation !?

File attachments


This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 25, 2007

Comment author: @Chris00

It seems that the better one can do is to follow the ISO/IEC 9899:1999 standard, annex G (IEC 60559-compatible complex arithmetic (informative), pages 465–478. ANSI, 1999.). Then

# Complex.div;;
- : Complex.t = {re = infinity; im = nan}

which is an infinity because a complex number with any infinite component is considered infinite (the only complex NaN is { re = nan; im = nan }. I have uploaded the file "" with an implementation of mul and div.

See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.