This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.

Exts.Int

Extensions to the core Int library.

floorBy : Int -> Int -> Maybe Int

Round an int down to the nearest multiple of a factor.

floorBy  2 143 => Just 142
floorBy 50 143 => Just 100
floorBy  0 143 => Nothing
module Exts.Int exposing (floorBy)

{-| Extensions to the core `Int` library.

@docs floorBy
-}


{-| Round an int down to the nearest multiple of a factor.

    floorBy  2 143 => Just 142
    floorBy 50 143 => Just 100
    floorBy  0 143 => Nothing
-}
floorBy : Int -> Int -> Maybe Int
floorBy factor n =
    if factor == 0 then
        Nothing
    else
        Just (factor * ((n // factor)))