Opened 8 years ago

Closed 8 years ago

# sign and more truncation functions on real intervals

Reported by: Owned by: Vincent Delecroix major sage-6.7 basic arithmetic Vincent Delecroix Jeroen Demeyer N/A 7fe18d6 7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e

Real intervals are missing truncation functions:

• `frac`
• `trunc`
• `round`
• `unique_sign`
• `unique_trunc`

We also add some more documentation to truncation methods.

### comment:1 Changed 8 years ago by Vincent Delecroix

Branch: → u/vdelecroix/18334 → d96885c0b700b6ae5f703dcf62dae6cf62323759 modified (diff) new → needs_review unique_sign and unique_trunc on real intervals → sign and more truncation functions on real intervals

New commits:

 ​d96885c `Trac 18334: sign and truncations for real intervals`

### comment:2 Changed 8 years ago by Vincent Delecroix

Description: modified (diff)

### comment:3 Changed 8 years ago by Jeroen Demeyer

Status: needs_review → needs_work

The `frac()` of an interval is not the same as

```self.parent()(self.lower().frac(), self.upper().frac())
```

For example, the `frac()` of `RIF(6,7)` should be the whole interval `RIF(0,1)`.

### comment:4 Changed 8 years ago by Jeroen Demeyer

The following would be a good doctest:

```sage: RIF(-0.9, 0.9).unique_trunc()
0
```

### comment:5 Changed 8 years ago by Jeroen Demeyer

Reviewers: → Jeroen Demeyer

### comment:6 follow-up:  8 Changed 8 years ago by Jeroen Demeyer

For `frac()`, you should check specifically if `-1` or `1` should be contained in the result:

• if the interval `]a,b]` contains a positive integer (check if `floor(b) > max(a,0)`): `frac()` must contain `[0,1]`
• if the interval `[a,b[` contains a negative integer (check if `ceil(a) < min(b,0)`): `frac()` must contain `[-1,0]`

If you add the `frac()` of the endpoints, you should get everything.

Last edited 8 years ago by Jeroen Demeyer (previous) (diff)

### comment:7 Changed 8 years ago by git

Commit: d96885c0b700b6ae5f703dcf62dae6cf62323759 → 10067b5735103012c8fcd0eba6e84d6cefa69573

Branch pushed to git repo; I updated commit sha1. New commits:

 ​10067b5 `Trac 18334: fixed frac + doctests`

### comment:8 in reply to:  6 Changed 8 years ago by Vincent Delecroix

For `frac()`, you should check specifically if `-1` or `1` should be contained in the result:

• if the interval `]a,b]` contains a positive integer (check if `floor(b) > max(a,0)`): `frac()` must contain `[0,1]`
• if the interval `[a,b[` contains a negative integer (check if `ceil(a) < min(b,0)`): `frac()` must contain `[-1,0]`

If you add the `frac()` of the endpoints, you should get everything.

Of course. This was completely wrong! Thanks.

### comment:9 Changed 8 years ago by Vincent Delecroix

Status: needs_work → needs_review

### comment:10 Changed 8 years ago by Jeroen Demeyer

Status: needs_review → needs_work

Add some comments like I wrote in 6. I would also like to see doctests where one endpoint is an integer:

```sage: RIF(0.5, 1).frac()
sage: RIF(1, 1.5).frac()
```

### comment:11 Changed 8 years ago by git

Commit: 10067b5735103012c8fcd0eba6e84d6cefa69573 → 3aa1904cab0c50d160a30051571bb69321654888

Branch pushed to git repo; I updated commit sha1. New commits:

 ​3aa1904 `Trac 18334: more doctests`

### comment:12 Changed 8 years ago by git

Commit: 3aa1904cab0c50d160a30051571bb69321654888 → 7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

 ​7fe18d6 `Trac 18334: more doctests`

### comment:13 Changed 8 years ago by Vincent Delecroix

Status: needs_work → needs_review

### comment:14 Changed 8 years ago by Jeroen Demeyer

Status: needs_review → positive_review

Thanks Jeroen!

### comment:16 Changed 8 years ago by Volker Braun

Branch: u/vdelecroix/18334 → 7fe18d6e2d9b459340c9c6e1527a6eb4ebd4e24e → fixed positive_review → closed
Note: See TracTickets for help on using tickets.