Reference fract()

fract()

Calculates the fractional part of a number.

A number's fractional part includes its decimal values. For example, fract(12.34) returns 0.34.

fract() can also be used in shaders with p5.strands. The following example uses fract() to create repeating patterns in a shader.

Examples

Syntax

fract(n)

Parameters

n
Number: number whose fractional part will be found.

Returns

Number: fractional part of n.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/calculation.js and open a pull request!

Related References