starscript icon indicating copy to clipboard operation
starscript copied to clipboard

Exponent notation of float numbers begin too early

Open Xenapte opened this issue 2 years ago • 10 comments

Currently float numbers (after conversion to string) are displayed using exponent notation if they are greater than 10^7, which is still within the limits of a normal Minecraft world, making it difficult to read if using Meteor Client to display coordinates beyond this point. There doesn't seem to be any workarounds.

20230309110406

Xenapte avatar Mar 09 '23 03:03 Xenapte

https://github.com/MeteorDevelopment/starscript/blob/20764f00d4dc47c4f6a8d4dd8d55b3220ceca104/src/main/java/org/meteordev/starscript/value/Value.java#L136

crosby-moe avatar Mar 09 '23 03:03 crosby-moe

Only happens with Double.toString(), so if the number has a fractional part, and is 10000000 or above

Probably possible to bypass it by rounding to an integer if the value reaches the threshold, so something like {z >= 10000000 ? round(z) : z}

crosby-moe avatar Mar 09 '23 03:03 crosby-moe

Yes I'm currently using this, having figured it out some hours ago. But it would be nicer if I'm still able to see some decimal places (i round them to 2 decimal places because sometimes I want to align myself to the center of tunnels).

Xenapte avatar Mar 09 '23 03:03 Xenapte

Yes I'm currently using this, having figured it out some hours ago. But it would be nicer if I'm still able to see some decimal places (i round them to 2 decimal places because sometimes I want to align myself to the center of tunnels).

You can do {round(x * 100) / 100} to achieve 2 decimal places iirc

crosby-moe avatar Mar 09 '23 04:03 crosby-moe

You can do {round(x * 100) / 100} to achieve 2 decimal places iirc

No, that still gives exponent notation. Thanks for the help tho

Xenapte avatar Mar 09 '23 05:03 Xenapte

You can do {round(x * 100) / 100} to achieve 2 decimal places iirc

No, that still gives exponent notation. Thanks for the help tho

Oh yeah you cant easily have both decimals and regular notation

crosby-moe avatar Mar 09 '23 12:03 crosby-moe

@Xenapte a bit late on this, but Pos: #1{player.pos.x >= 10000000 ? round(player.pos.x) : round(player.pos.x * 100) / 100} {round(player.pos.y * 100) / 100} {player.pos.z >= 10000000 ? round(player.pos.z) : round(player.pos.z * 100) / 100} should be what you're after

crosby-moe avatar Mar 13 '23 00:03 crosby-moe

Sorry for the late reply, but still the problem persists using this (I wanted to see 2 decimal places for numbers larger than 10 million) - though I did tweak this to be more robust for different coordinates: Pos: #1{abs(player.pos.x) >= 10000000 ? floor(round(player.pos.x)) : round(player.pos.x, 2)}, {round(player.pos.y, 2)}, {abs(player.pos.z) >= 10000000 ? floor(round(player.pos.z)) : round(player.pos.z, 2)}. For now I'm going to just try to get used to integer displays for large numbers.

Xenapte avatar Mar 15 '23 11:03 Xenapte

Sorry for the late reply, but still the problem persists using this (I wanted to see 2 decimal places for numbers larger than 10 million) - though I did tweak this to be more robust for different coordinates: Pos: #1{abs(player.pos.x) >= 10000000 ? floor(round(player.pos.x)) : round(player.pos.x, 2)}, {round(player.pos.y, 2)}, {abs(player.pos.z) >= 10000000 ? floor(round(player.pos.z)) : round(player.pos.z, 2)}. For now I'm going to just try to get used to integer displays for large numbers.

Yeah I will try to fix the big decimals in the starscript source itself

crosby-moe avatar Mar 15 '23 17:03 crosby-moe

Thanks!

Xenapte avatar Mar 16 '23 06:03 Xenapte