Change helper into BigDecimal method

This commit is contained in:
2024-12-06 15:24:25 +01:00
parent 2e4eb3d4b5
commit 7e5f873cde
3 changed files with 23 additions and 25 deletions

View File

@@ -132,28 +132,4 @@ module ApplicationHelper
def disabled_attributes(disabled)
disabled ? {disabled: true, aria: {disabled: true}, tabindex: -1} : {}
end
private
# Converts value to HTML formatted scientific notation
def scientifize(d)
sign, coefficient, base, exponent = d.split
return 'NaN' unless sign
result = (sign == -1 ? '-' : '')
unless coefficient == '1' && sign == 1
if coefficient.length > 1
result += coefficient.insert(1, '.')
elsif
result += coefficient
end
if exponent != 1
result += "×"
end
end
if exponent != 1
result += "10<sup>% d</sup>" % [exponent-1]
end
result.html_safe
end
end