NumericSuffixes

Shorthand numeric conversions.

Contents

Installation

This package is registered in METADATA.jl and so can be installed using Pkg.add

Pkg.add("NumericSuffixes")

Public Interface

# NumericSuffixesModule.

Provides the @suffix macro for generating shorthand numeric conversion suffixes.

Examples

x = 1i8        # Convert `1` to `Int8`.
y = 3u32       # Convert `3` to `UInt32`.
z = (x + y)r16 # Convert `4` to `Float16`.

Default Suffixes

16 suffixes are provided by default:

  • i8 --> Int8
  • i16 --> Int16
  • i32 --> Int32
  • i64 --> Int64
  • i128 --> Int128
  • u8 --> UInt8
  • u16 --> UInt16
  • u32 --> UInt32
  • u64 --> UInt64
  • u128 --> UInt128
  • r16 --> Float16
  • r32 --> Float32
  • r64 --> Float64
  • c32 --> Complex32
  • c64 --> Complex64
  • c128 --> Complex128

Additional user defined suffixes can be made using the @suffix macro.

source

# NumericSuffixes.@suffixMacro.

Generate a new numeric suffix named n which converts numbers to type T.

Signature

@suffix n T

Examples

@suffix i8 Int8

x = 1i8
typeof(x) == Int8

More complex conversions can be made using anonymous function syntax:

@suffix t16 x -> trunc(Int16, x)

x = 1.2t16
typeof(x) == Int16

source

Methods

Default Suffixes

Signed Integers

# NumericSuffixes.i8Type.

Numeric suffix for Int8 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.i16Type.

Numeric suffix for Int16 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.i32Type.

Numeric suffix for Int32 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.i64Type.

Numeric suffix for Int64 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.i128Type.

Numeric suffix for Int128 values.

source

Methods

Hiding 1 method defined outside of this package.

Unsigned Integers

# NumericSuffixes.u8Type.

Numeric suffix for UInt8 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.u16Type.

Numeric suffix for UInt16 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.u32Type.

Numeric suffix for UInt32 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.u64Type.

Numeric suffix for UInt64 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.u128Type.

Numeric suffix for UInt128 values.

source

Methods

Hiding 1 method defined outside of this package.

Floating Point Numbers

# NumericSuffixes.r16Type.

Numeric suffix for Float16 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.r32Type.

Numeric suffix for Float32 values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.r64Type.

Numeric suffix for Float64 values.

source

Methods

Hiding 1 method defined outside of this package.

Complex Floating Point Numbers

# NumericSuffixes.c32Type.

Numeric suffix for Complex{Float16} values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.c64Type.

Numeric suffix for Complex{Float32} values.

source

Methods

Hiding 1 method defined outside of this package.

# NumericSuffixes.c128Type.

Numeric suffix for Complex{Float64} values.

source

Methods

Hiding 1 method defined outside of this package.