Matlab Truncate Function In Javascript