I don't think it's a too difficult of a script to make, but I'll post it since I've never seen it.
Turns decimals into fractions. yay
Sample output:
$div(.5) -> 1/2
$div(.333) -> 1/3
$div(1.5) -> 3/2
$div(.342857) -> 12/35
A note on the number of significant figures. When doing something like 12/35 where the number of sigfigs is exactly 6, try to use 6. On numbers such as 1/3 where its continuous, it's recommended to use 4.
alias frac {
var %x 1,%t $mid($1,$pos($1,.,1),0) - 1,%p
while (%x) {
%p = $round($calc($v1 * $1),0)
if ($round($calc($+(%p,/,$v1)),%t) == $1) return $+(%p,/,%x)
inc %x
}
}
hi
sorry about my language i don't speak verry well english
no need to "return $false"
u was declared %p local why u retype var %p down? type only %p = ...
the variable %y and %t just for len of number after the point?
put only "%t $mid($1,$pos($1,.,1),0) - 1"
no need $round($1,%t) type only $1 cz the %t is the len of number after the point
so
alias frac {
var %x 1,%t $mid($1,$pos($1,.,1),0) - 1,%p
while (%x) {
%p = $round($calc($v1 * $1),0)
if ($round($calc($+(%p,/,$v1)),%t) == $1) return $+(%p,/,%x)
inc %x
}
}