## Feature #206

### Is NaN accepted with g*math ISFINITE?

Status: | Closed | Start date: | 2013-01-28 | |
---|---|---|---|---|

Priority: | Normal | Due date: | ||

Assignee: | - | % Done: | 0% | |

Category: | - | |||

Target version: | Candidate for next minor release | |||

Platform: | Linux |

**Description**

~$ gmtmath -Q 0 INV =

gmtmath (table_INV): Warning: Inverse of zero gives NaNs

NaN

~$ gmtmath -Q 0 INV ISFINITE =

gmtmath (table_INV): Warning: Inverse of zero gives NaNs

0

~$ gmtmath -Q NaN ISFINITE =

gmtmath (decode_gmt_argument): Syntax error: NaN is not a number, operator or file name

### History

#### #1 Updated by Paul over 4 years ago

**Status**changed from*New*to*Resolved*

Works now. NaN was not accepted anywhere in gmtmath as perhaps it was not thought a useful argument. In r10824.

#### #2 Updated by Eduardo over 4 years ago

OK now works!

$ gmtmath -Q NaN ISFINITE =

0

$ gmtmath -Q NaN ISNAN =

1

and this is great!!! (some warnings must say [+/-]inf instead of NaN) (+/-inf it isn't documented)

$ gmtmath -Q 1 0 DIV =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

inf

$ gmtmath -Q -1 0 DIV =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

-inf

$ gmtmath -Q 0 0 DIV =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

NaN

$ gmtmath -Q 1 0 DIV 5 0 DIV EQ =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

1

but...

$ gmtmath -Q 1 0 DIV =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

inf

$ gmtmath -Q 0 INV =

gmtmath (table_INV): Warning: Inverse of zero gives NaNs

NaN

both must be inf

and...

$ gmtmath -Q 1 inf DIV =

gmtmath (decode_gmt_argument): Syntax error: inf is not a number, operator or file name

must be 0 positive like

$ gmtmath -Q 1 1 0 DIV DIV =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

0

great!

$ gmtmath -Q 1 -1 0 DIV DIV =

gmtmath (table_DIV): Warning: Divide by zero gives NaNs

-0

and this doesn't work

$ gmtmath -Q NaN NaN EQ =

0

$ gmtmath -Q NaN NaN NEQ =

1

I don't know if this is important

#### #3 Updated by Paul over 4 years ago

Eduardo, GMT does not internally handle +/- inf as for most purposes it makes no difference if inf or NaN. Most of the time GMT will just report NaN even though it should be inf. Likewise, reading inf on the command line has not been considered a priority either. We may be able to clean up a bit but this only makes a difference in special scripting cases where you are trying to catch a NaN or and inf, presumably.

#### #4 Updated by Florian over 3 years ago

**Target version**changed from*5.1.0*to*Candidate for next minor release*

#### #5 Updated by Joaquim about 2 years ago

**Status**changed from*Resolved*to*Closed*