# Rationals are now Numbers: The SWI Prolog doc needs an update

**URL:** <https://swi-prolog.discourse.group/t/rationals-are-now-numbers-the-swi-prolog-doc-needs-an-update/2133>\
**Category:** SWI-Prolog web site and services\
**Tags:** discussion\
**Created:** [April 9, 2020, 2:44pm UTC](https://swi-prolog.discourse.group/t/rationals-are-now-numbers-the-swi-prolog-doc-needs-an-update/2133 "2020-04-09T14:44:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtonhofer](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/dtonhofer/32/902_2.png) [@dtonhofer](https://swi-prolog.discourse.group/u/dtonhofer)\
**Post date:** [April 9, 2020, 2:44pm UTC](https://swi-prolog.discourse.group/t/rationals-are-now-numbers-the-swi-prolog-doc-needs-an-update/2133/1 "2020-04-09T14:44:21Z")

</div>

I have just noticed that the following succeeds:

`?- X is 3r7, rational(X), number(X), atomic(X), \+atom(X), format("~q",[X]).`

[The documentation for `number/1`](https://eu.swi-prolog.org/pldoc/doc_for?object=number/1) still says

> As rational numbers are not atomic in the current implementation and we do not want to break the rule that [number/1](https://eu.swi-prolog.org/pldoc/man?predicate=number/1) implies [atomic/1](https://eu.swi-prolog.org/pldoc/man?predicate=atomic/1), [number/1](https://eu.swi-prolog.org/pldoc/man?predicate=number/1) fails on rational numbers. This will change if rational numbers become atomic.

Well, the rational numbers are atomic now.

Btw, is there a way to “inspect” the “integer” that is currently in an `X`. To decide whether it is a machine integer or an integer from GMP. A bit in the spirit of `float_parts/4`. I can’t directly think of a use for that, but having an inspection trap to the bilge is always good.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 10, 2020, 2:11pm UTC](https://swi-prolog.discourse.group/t/rationals-are-now-numbers-the-swi-prolog-doc-needs-an-update/2133/2 "2020-04-10T14:11:09Z")

</div>

Thanks. Fixed.

> [@dtonhofer](#):
>
> is there a way to “inspect” the “integer”

No. Floats have “parts” by their very nature of being defined as _mantissa\*base^exp_. Rationals are _D/N_, but integer is (AFAIK) a basic numeric concept. SWI-Prolog deliberately does not provide insight in how things are internally represented. GMP may be replaced, notably if commercial users who require unbounded arithmetic by do not want the GMP LGPL license initiate this.

At this moment, any integer that does not fit into a 64 bit signed int is a GMP mpz type and all rationals (not being an integer) are GMP mpq type.
