in reply to Re: Re: Help with decimals
in thread Help with decimals

Acutally a regex isn't all that good of an idea. It's very slow. But substr is better than chop.. benchmarks included..

Benchmark: timing 100000 iterations of chop, math, regex, substr... chop: 6 wallclock secs ( 4.92 usr + 0.03 sys = 4.95 CPU) @ 202 +02.02/s (n=100000) math: 2 wallclock secs ( 1.07 usr + 0.02 sys = 1.09 CPU) @ 917 +43.12/s (n=100000) regex: 25 wallclock secs (17.40 usr + 0.32 sys = 17.72 CPU) @ 56 +43.34/s (n=100000) substr: 2 wallclock secs ( 1.99 usr + 0.03 sys = 2.02 CPU) @ 495 +04.95/s (n=100000)
Doing the math is still the best option..