{"id":16000581,"url":"https://github.com/jedwards1211/mod-floor-ceiling","last_synced_at":"2025-08-16T21:06:39.257Z","repository":{"id":57300237,"uuid":"89632895","full_name":"jedwards1211/mod-floor-ceiling","owner":"jedwards1211","description":"computes floor and ceiling for any modulus, not just 1","archived":false,"fork":false,"pushed_at":"2017-11-29T05:33:41.000Z","size":87,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T17:48:42.524Z","etag":null,"topics":["ceiling","floor","javascript","math","mod","modular-arithmetic","modulo"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jedwards1211.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-27T19:26:45.000Z","updated_at":"2018-01-25T14:29:14.000Z","dependencies_parsed_at":"2022-08-22T22:40:58.876Z","dependency_job_id":null,"html_url":"https://github.com/jedwards1211/mod-floor-ceiling","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedwards1211%2Fmod-floor-ceiling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedwards1211%2Fmod-floor-ceiling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedwards1211%2Fmod-floor-ceiling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jedwards1211%2Fmod-floor-ceiling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jedwards1211","download_url":"https://codeload.github.com/jedwards1211/mod-floor-ceiling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247271527,"owners_count":20911587,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ceiling","floor","javascript","math","mod","modular-arithmetic","modulo"],"created_at":"2024-10-08T09:04:53.376Z","updated_at":"2025-04-05T01:14:52.672Z","avatar_url":"https://github.com/jedwards1211.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mod-floor-ceiling\n\n[![Build Status](https://travis-ci.org/jedwards1211/mod-floor-ceiling.svg?branch=master)](https://travis-ci.org/jedwards1211/mod-floor-ceiling)\n[![Coverage Status](https://coveralls.io/repos/github/jedwards1211/mod-floor-ceiling/badge.svg?branch=master)](https://coveralls.io/github/jedwards1211/mod-floor-ceiling?branch=master)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\ncomputes floor and ceiling for any modulus, not just 1\n\n```\nnode\n\u003e require('mod-floor-ceiling').modFloor(3.8, 1.7)\n3.4\n\u003e require('mod-floor-ceiling').modFloor(3.4, 1.7)\n3.4\n\u003e require('mod-floor-ceiling').modCeiling(-17.8, 2.5)\n-17.5\n\u003e require('mod-floor-ceiling').modLower(15, 5)\n10\n\u003e require('mod-floor-ceiling').modLower(16, 5)\n15\n\u003e require('mod-floor-ceiling').modHigher(15, 5)\n20\n\u003e require('mod-floor-ceiling').modHigher(14, 5)\n15\n\n```\n\n## Usage\n\n```\nnpm install mod-floor-ceiling\n```\n\n### `modFloor(value: number, modulus: number, anchor?: number = 0): number`\n\nReturns the greatest (closest to positive infinity) multiple of `modulus`, plus `anchor`, that is `\u003c= value`.\n\n### `modCeiling(value: number, modulus: number, anchor?: number = 0): number`\n\nReturns the least (closest to negative infinity) multiple of `modulus`, plus `anchor`, that is `\u003e= value`.\n\n### `modLower(value: number, modulus: number, anchor?: number = 0): number`\n\nReturns the greatest (closest to positive infinity) multiple of `modulus`, plus `anchor`, that is `\u003c value`.\n\n### `modHigher(value: number, modulus: number, anchor?: number = 0): number`\n\nReturns the greatest (closest to positive infinity) multiple of `modulus`, plus `anchor`, that is `\u003e value`.\n\n### What is `anchor`?\n\n**Anchor controls the offset of multiples of modulus.**\n\nFor example, with a modulus of 3 and the default anchor of 0, possible return values include -6, -3, 0, 3, 6, etc.\n\nBut with anchor of 1, possible return values include -5, -2, 1, 4, 7, etc.\n\nIt's simple; `modFloor(value, modulus, anchor)` just computes `anchor + modFloor(value - anchor, modulus)`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedwards1211%2Fmod-floor-ceiling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjedwards1211%2Fmod-floor-ceiling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjedwards1211%2Fmod-floor-ceiling/lists"}