Fixed floating point exponential notation in miner/calculate page
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2023-05-26 05:57:50 +02:00
parent 49199bf61c
commit 3b14cc2323
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
3 changed files with 8 additions and 3 deletions

View file

@ -16,7 +16,7 @@
</p>
<div>
<label for="hashrate">Your Hashrate</label><br/>
<input type="numeric" name="hashrate" id="hashrate" placeholder="100" size="8" class="mono" value="{% if hashrate > 0 %}{{ hashrate }}{% endif %}"/>
<input type="numeric" name="hashrate" id="hashrate" placeholder="100" size="8" class="mono" value="{% if hashrate > 0 %}{{ hashrate|str }}{% endif %}"/>
<select name="magnitude">
<option value="1"{% if magnitude == 1 %} selected{% endif %}>H/s</option>
<option value="1000"{% if magnitude == 1000 %} selected{% endif %}>KH/s</option>

View file

@ -211,7 +211,7 @@
<p>Local hashrate of each P2Pool miner is not known by the network. A guess is calculated based on daily estimation. If you provide a value here, it will be more accurate for effort calculation.</p>
<p>This data will not be saved.</p>
<label for="hashrate_local">Your Local Hashrate</label><br/>
<input type="numeric" name="hashrate" id="hashrate_local" placeholder="100" size="8" class="mono" value="{% if hashrate_local > 0 %}{{ hashrate_local }}{% endif %}"/>
<input type="numeric" name="hashrate" id="hashrate_local" placeholder="100" size="8" class="mono" value="{% if hashrate_local > 0 %}{{ hashrate_local|str }}{% endif %}"/>
<select name="magnitude">
<option value="1"{% if magnitude_local == 1 %} selected{% endif %}>H/s</option>
<option value="1000"{% if magnitude_local == 1000 %} selected{% endif %}>KH/s</option>

View file

@ -752,7 +752,12 @@ func main() {
if strVal, ok := val.(fmt.Stringer); ok {
return strVal.String()
}
return strconv.FormatUint(toUint64(val), 10)
switch val.(type) {
case float64, float32:
return strconv.FormatFloat(toFloat64(val), 'f', -1, 64)
default:
return strconv.FormatUint(toUint64(val), 10)
}
}
env.Tests["defined"] = func(ctx stick.Context, val stick.Value, args ...stick.Value) bool {
return val != nil