Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/usePrecision.md
1---2category: '@Math'3---45# usePrecision67Reactively set the precision of a number.89## Usage1011```ts12import { usePrecision } from '@vueuse/math'1314const value = ref(3.1415)15const result = usePrecision(value, 2) // 3.141617const ceilResult = usePrecision(value, 2, {18math: 'ceil'19}) // 3.152021const floorResult = usePrecision(value, 3, {22math: 'floor'23}) // 3.14124```2526## Type Declarations2728```ts29export interface UsePrecisionOptions {30/**31* Method to use for rounding32*33* @default 'round'34*/35math?: "floor" | "ceil" | "round"36}37/**38* Reactively set the precision of a number.39*40* @see https://vueuse.org/usePrecision41*42* @__NO_SIDE_EFFECTS__43*/44export declare function usePrecision(45value: MaybeRefOrGetter<number>,46digits: MaybeRefOrGetter<number>,47options?: MaybeRefOrGetter<UsePrecisionOptions>,48): ComputedRef<number>49```50