/Pony

# Integer[A: Integer[A] val]

[Source]

```trait val Integer[A: Integer[A] val] is
Real[A] val
```

## Constructors

### create

[Source]

```new val create(
value: A)
: Real[A] val^
```

• value: A

### from[B: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val | U8 val | U16 val | U32 val | U64 val | U128 val | ULong val | USize val | F32 val | F64 val) & Real[B] val)]

[Source]

```new val from[B: ((I8 val | I16 val | I32 val |
I64 val | I128 val | ILong val |
ISize val | U8 val | U16 val |
U32 val | U64 val | U128 val |
ULong val | USize val | F32 val |
F64 val) & Real[B] val)](
a: B)
: Real[A] val^
```

• a: B

### min_value

[Source]

```new val min_value()
: Real[A] val^
```

### max_value

[Source]

```new val max_value()
: Real[A] val^
```

## Public Functions

[Source]

Unsafe operation. If the operation overflows, the result is undefined.

```fun box add_unsafe(
y: A)
: A
```

• y: A

• A

### sub_unsafe

[Source]

Unsafe operation. If the operation overflows, the result is undefined.

```fun box sub_unsafe(
y: A)
: A
```

• y: A

• A

### mul_unsafe

[Source]

Unsafe operation. If the operation overflows, the result is undefined.

```fun box mul_unsafe(
y: A)
: A
```

• y: A

• A

### div_unsafe

[Source]

Integer division, rounded towards zero.

Unsafe operation. If y is 0, the result is undefined. If the operation overflows, the result is undefined.

```fun box div_unsafe(
y: A)
: A
```

• y: A

• A

### divrem_unsafe

[Source]

Calculates the quotient of this number and `y` and the remainder.

Unsafe operation. If y is 0, the result is undefined. If the operation overflows, the result is undefined.

```fun box divrem_unsafe(
y: A)
: (A , A)
```

• y: A

• (A , A)

### rem_unsafe

[Source]

Calculates the remainder of this number divided by `y`.

Unsafe operation. If y is 0, the result is undefined. If the operation overflows, the result is undefined.

```fun box rem_unsafe(
y: A)
: A
```

• y: A

• A

### fld_unsafe

[Source]

Floored division, rounded towards negative infinity, as opposed to `div` which rounds towards zero.

Unsafe Operation

If y is 0, the result is undefined. If the operation overflows, the result is undefined.

```fun box fld_unsafe(
y: A)
: A
```

• y: A

• A

### mod_unsafe

[Source]

Calculates the modulo of this number after floored division by `y`.

Unsafe Operation.

If y is 0, the result is undefined. If the operation overflows, the result is undefined.

```fun box mod_unsafe(
y: A)
: A
```

• y: A

#### Returns

• A

[Source]

If the operation overflows this function errors.

```fun box add_partial(
y: A)
: A ?
```

• y: A

• A ?

### sub_partial

[Source]

Subtract y from this number.

If the operation overflows/underflows this function errors.

```fun box sub_partial(
y: A)
: A ?
```

• y: A

• A ?

### mul_partial

[Source]

Multiply y with this number.

If the operation overflows this function errors.

```fun box mul_partial(
y: A)
: A ?
```

• y: A

• A ?

### div_partial

[Source]

Divides this number by `y`, rounds the result towards zero.

If y is `0` or the operation overflows, this function errors.

```fun box div_partial(
y: A)
: A ?
```

• y: A

• A ?

### rem_partial

[Source]

Calculates the remainder of this number divided by y. The result has the sign of the dividend.

If y is `0` or the operation overflows, this function errors.

```fun box rem_partial(
y: A)
: A ?
```

• y: A

• A ?

### divrem_partial

[Source]

Divides this number by y and calculates the remainder of the operation.

If y is `0` or the operation overflows, this function errors.

```fun box divrem_partial(
y: A)
: (A , A) ?
```

• y: A

• (A , A) ?

### fld_partial

[Source]

Floored integer division, rounded towards negative infinity.

If y is `0` or the operation overflows, this function errors

```fun box fld_partial(
y: A)
: A ?
```

• y: A

• A ?

### mod_partial

[Source]

Calculates the modulo of this number and `y` after floored division (`fld`). The result has the sign of the divisor.

If y is `0` or the operation overflows, this function errors.

```fun box mod_partial(
y: A)
: A ?
```

• y: A

• A ?

### neg_unsafe

[Source]

Unsafe operation. If the operation overflows, the result is undefined.

```fun box neg_unsafe()
: A
```

#### Returns

• A

[Source]

Add `y` to this integer and return the result and a flag indicating overflow.

```fun box addc(
y: A)
: (A , Bool val)
```

• y: A

### subc

[Source]

Subtract `y` from this integer and return the result and a flag indicating overflow.

```fun box subc(
y: A)
: (A , Bool val)
```

• y: A

### mulc

[Source]

Multiply `y` with this integer and return the result and a flag indicating overflow.

```fun box mulc(
y: A)
: (A , Bool val)
```

• y: A

### divc

[Source]

Divide this integer by `y` and return the result and a flag indicating overflow or division by zero.

```fun box divc(
y: A)
: (A , Bool val)
```

• y: A

### remc

[Source]

Calculate the remainder of this number divided by `y` and return the result and a flag indicating division by zero or overflow.

The result will have the sign of the dividend.

```fun box remc(
y: A)
: (A , Bool val)
```

• y: A

### fldc

[Source]

Divide this integer by `y` and return the result, rounded towards negative infinity and a flag indicating overflow or division by zero.

```fun box fldc(
y: A)
: (A , Bool val)
```

• y: A

### modc

[Source]

Calculate the modulo of this number after floored division by `y` and return the result and a flag indicating division by zero or overflow.

The result will have the sign of the divisor.

```fun box modc(
y: A)
: (A , Bool val)
```

• y: A

### op_and

[Source]

```fun box op_and(
y: A)
: A
```

• y: A

• A

### op_or

[Source]

```fun box op_or(
y: A)
: A
```

• y: A

• A

### op_xor

[Source]

```fun box op_xor(
y: A)
: A
```

• y: A

• A

### op_not

[Source]

```fun box op_not()
: A
```

• A

### bit_reverse

[Source]

Reverse the order of the bits within the integer. For example, 0b11101101 (237) would return 0b10110111 (183).

```fun box bit_reverse()
: A
```

• A

### bswap

[Source]

```fun box bswap()
: A
```

#### Returns

• A

[Source]

```fun box add(
y: A)
: A
```

• y: A

• A

### sub

[Source]

```fun box sub(
y: A)
: A
```

• y: A

• A

### mul

[Source]

```fun box mul(
y: A)
: A
```

• y: A

• A

### div

[Source]

```fun box div(
y: A)
: A
```

• y: A

• A

### divrem

[Source]

```fun box divrem(
y: A)
: (A , A)
```

• y: A

• (A , A)

### rem

[Source]

```fun box rem(
y: A)
: A
```

• y: A

• A

### neg

[Source]

```fun box neg()
: A
```

• A

### fld

[Source]

```fun box fld(
y: A)
: A
```

• y: A

• A

### mod

[Source]

```fun box mod(
y: A)
: A
```

• y: A

• A

### eq

[Source]

```fun box eq(
y: box->A)
: Bool val
```

• y: box->A

### ne

[Source]

```fun box ne(
y: box->A)
: Bool val
```

• y: box->A

### lt

[Source]

```fun box lt(
y: box->A)
: Bool val
```

• y: box->A

### le

[Source]

```fun box le(
y: box->A)
: Bool val
```

• y: box->A

### ge

[Source]

```fun box ge(
y: box->A)
: Bool val
```

• y: box->A

### gt

[Source]

```fun box gt(
y: box->A)
: Bool val
```

• y: box->A

### min

[Source]

```fun box min(
y: A)
: A
```

• y: A

• A

### max

[Source]

```fun box max(
y: A)
: A
```

• y: A

• A

### hash

[Source]

```fun box hash()
: USize val
```

### hash64

[Source]

```fun box hash64()
: U64 val
```

### string

[Source]

```fun box string()
: String iso^
```

### i8

[Source]

```fun box i8()
: I8 val
```

### i16

[Source]

```fun box i16()
: I16 val
```

### i32

[Source]

```fun box i32()
: I32 val
```

### i64

[Source]

```fun box i64()
: I64 val
```

### i128

[Source]

```fun box i128()
: I128 val
```

### ilong

[Source]

```fun box ilong()
: ILong val
```

### isize

[Source]

```fun box isize()
: ISize val
```

### u8

[Source]

```fun box u8()
: U8 val
```

### u16

[Source]

```fun box u16()
: U16 val
```

### u32

[Source]

```fun box u32()
: U32 val
```

### u64

[Source]

```fun box u64()
: U64 val
```

### u128

[Source]

```fun box u128()
: U128 val
```

### ulong

[Source]

```fun box ulong()
: ULong val
```

### usize

[Source]

```fun box usize()
: USize val
```

### f32

[Source]

```fun box f32()
: F32 val
```

### f64

[Source]

```fun box f64()
: F64 val
```

### i8_unsafe

[Source]

```fun box i8_unsafe()
: I8 val
```

### i16_unsafe

[Source]

```fun box i16_unsafe()
: I16 val
```

### i32_unsafe

[Source]

```fun box i32_unsafe()
: I32 val
```

### i64_unsafe

[Source]

```fun box i64_unsafe()
: I64 val
```

### i128_unsafe

[Source]

```fun box i128_unsafe()
: I128 val
```

### ilong_unsafe

[Source]

```fun box ilong_unsafe()
: ILong val
```

### isize_unsafe

[Source]

```fun box isize_unsafe()
: ISize val
```

### u8_unsafe

[Source]

```fun box u8_unsafe()
: U8 val
```

### u16_unsafe

[Source]

```fun box u16_unsafe()
: U16 val
```

### u32_unsafe

[Source]

```fun box u32_unsafe()
: U32 val
```

### u64_unsafe

[Source]

```fun box u64_unsafe()
: U64 val
```

### u128_unsafe

[Source]

```fun box u128_unsafe()
: U128 val
```

### ulong_unsafe

[Source]

```fun box ulong_unsafe()
: ULong val
```

### usize_unsafe

[Source]

```fun box usize_unsafe()
: USize val
```

### f32_unsafe

[Source]

```fun box f32_unsafe()
: F32 val
```

### f64_unsafe

[Source]

```fun box f64_unsafe()
: F64 val
```

### compare

```fun box compare(
that: box->A)
: (Less val | Equal val | Greater val)
```

• that: box->A

## Private Functions

### _value

[Source]

```fun box _value()
: A
```

• A