thegrumpys / odop

Open Design Optimization Platform (ODOP) - Coil spring design app; mechanical springs; compression spring, extension spring, torsion spring
https://www.springdesignsoftware.org
MIT License
4 stars 5 forks source link

Extreme values display as blank #874

Closed grumpyinca closed 10 months ago

grumpyinca commented 11 months ago

This may be a problem in toODOPprecision().

In Javascript, Number.MAX_VALUE has the value of 1.7976931348623157e+308. In ODOP, entering values greater than 1.797e+308 will cause the associated field to display as blank. This appears to be the case with negative values as well.

Note that toODOPprecision() is designed to display four significant digits for numbers in scientific notation.

In Javascript, Number.MIN_VALUE has a value of 5e-324. In ODOP, entering values close to and on either side of this number causes unexpected behavior, but is never rendered as blank. Eventually, if a sufficiently small number is entered, it will be rendered as zero.

1fifoto commented 10 months ago

Replaced multiple internal definitions of:

Number.prototype.toODOPPrecision = function() {
    ...
}

with toODOPPrecision.js file containing:

export function toODOPPrecision(value) {
    ...
}
grumpyinca commented 10 months ago

Merged to master; pushed to remote. Closing.