Contact: aviboots(AT)netvision.net.il
43,181 questions
56,073 answers
573 users
function firstDecimalDigit(f) { const s = f.toString(); const pos = s.indexOf('.'); return s[pos + 1]; } const f = 231.687612; console.log(firstDecimalDigit(f)); // "6" /* run: 6 */
function firstDecimalDigit(f) { return f.toString().split('.')[1][0]; } const f = 231.687612; console.log(firstDecimalDigit(f)); // "6" /* run: 6 */
function firstDecimalDigit(f) { return (Math.floor(Math.abs(f) * 10)) % 10; } const f = 231.687612; console.log(firstDecimalDigit(f)); // 6 /* run: 6 */