mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-11-04 21:24:00 +01:00
26 lines
473 B
JavaScript
26 lines
473 B
JavaScript
class stringFloat{
|
|
constructor(value,printNaN=true) {
|
|
this.string=value
|
|
this.printNaN=printNaN
|
|
}
|
|
get Value(){
|
|
return parseFloat(this.string)
|
|
}
|
|
valueOf() {
|
|
return this.Value;
|
|
}
|
|
toString(){
|
|
if (checkFloat(this.string) && this.printNaN) {
|
|
return this.string
|
|
} else {
|
|
return NaN.toString()
|
|
}
|
|
}
|
|
}
|
|
function checkFloat(string) {
|
|
try {
|
|
return !Number.isNaN(parseFloat(string))
|
|
} catch (error) {
|
|
return false
|
|
}
|
|
} |