Skip to content

Commit 9a8aac4

Browse files
committed
propose sane arithmetic and shift operation semantics
1 parent 56d6607 commit 9a8aac4

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

text/0000-ppv.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,48 @@ pub unsafe fn load_unaligned_unchecked(slice: &[element_type]) -> Self;
512512
}
513513
```
514514

515+
#### Vertical arithmetic operations
516+
517+
Vertical (lane-wise) arithmetic operations are provided by the following trait
518+
implementations:
519+
520+
* All signed integer, unsigned integer, and floating point vector types implement:
521+
522+
* `{Add,Sub,Mul,Div,Rem}<RHS=Self,Output=Self>`
523+
* `{Add,Sub,Mul,Div,Rem}Assign<RHS=Self>`
524+
525+
* All signed and unsigned integer vectors also implement:
526+
527+
* `{Shl,Shr}<RHS=Self,Output=Self>`, `{Shl,Shr}Assign<RHS=Self>`: vertical
528+
(lane-wise) bit-shift operations.
529+
530+
##### Integer vector semantics
531+
532+
The behavior of these operations for integer vectors is the same as that of the
533+
scalar integer types. That is: `panic!` on both overflow and division by zero.
534+
535+
##### Floating-point semantics
536+
537+
The behavior of these operations for floating-point numbers is the same as that
538+
of the scalar floating point types, that is, `+-INFINITY` on overflow, `NaN` on
539+
division by zero, etc.
540+
541+
#### Wrapping arithmetic operations
542+
543+
All signed and unsigned integer vector types implement the whole set of `pub fn
544+
wrapping_{add,sub,mul,div,rem}(self, Self) -> Self` methods which, on overflow,
545+
produce the correct mathematical result modulo `2^n`.
546+
547+
The `div` and `rem` method `panic!` on division by zero.
548+
549+
#### Unsafe wrapping arithmetic operations
550+
551+
All signed and unsigned integer vectors implement
552+
`pub unsafe fn wrapping_{div,rem}_unchecked(self, Self) -> Self`
553+
methods which, on overflow, produce the correct mathematical result modulo `2^n`.
554+
555+
If any of the vector elements is divided by zero the behavior is undefined.
556+
515557
#### Binary minmax vertical operations
516558

517559
All portable signed integer, unsigned integer, and floating-point vectors

0 commit comments

Comments
 (0)