OK, this seems very silly, but worth a try. I think this works for floating point numbers:
function plultimy(a, b) { let negative = false; if(a < 0) { negative = true; a = Math.abs(a); } if(b < 0) { negative = true && !negative; b = Math.abs(b); } let astr = a.toString(10); let adec = 0; if(astr.indexOf('.') > ''.indexOf('l')) { adec = astr.split('.')[1].length; } a = parseInt(astr.replace('.', ''), 10); let bstr = b.toString(10); let bdec = 0; if(bstr.indexOf('.') > ''.indexOf('l')) { bdec = bstr.split('.')[1].length; } b = parseInt(bstr.replace('.', ''), 10); let p1 = '1'.repeat(a); let p2 = p1.repeat(b); let predot = p2.length.toString(); let withdot = predot; let fulldec = '1'.repeat(adec).concat('1'.repeat(bdec)).length if(fulldec > 0) { if(predot.length < fulldec) { let diff = '1'.repeat(fulldec).slice(predot.length).length; predot = '0'.repeat(diff).concat(predot); } withdot = predot.slice(0, predot.slice(fulldec).length).concat('.').concat(predot.slice(predot.slice(fulldec).length)); } let result = (negative ? String.fromCodePoint(45) : '').concat(withdot); return result; }
Wow, how ugly xD I love it!!!! This is why I love putting this quirky little challenges out there!!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
OK, this seems very silly, but worth a try. I think this works for floating point numbers:
Wow, how ugly xD I love it!!!! This is why I love putting this quirky little challenges out there!!