I need 0.000001 to be left as it is, but g option converts it to e notationFanaticGuru wrote:It would seem that a simple Format will handle most of what is needed.
Code: Select all
MsgBox % Format("{1:g}", 0.000001 ) ; 1e-006
I need 0.000001 to be left as it is, but g option converts it to e notationFanaticGuru wrote:It would seem that a simple Format will handle most of what is needed.
Code: Select all
MsgBox % Format("{1:g}", 0.000001 ) ; 1e-006
Old post but, you want f for plain old floating point.Suresh wrote: ↑21 Jul 2017, 16:09I need 0.000001 to be left as it is, but g option converts it to e notationFanaticGuru wrote:It would seem that a simple Format will handle most of what is needed.
which is not even valid for AHK math operations. The result should be 1.0e-006 to be a valid number.Code: Select all
MsgBox % Format("{1:g}", 0.000001 ) ; 1e-006
carno wrote: ↑29 Jan 2019, 11:58How can this be modified so that I can trim the leading floating zeros only after the decimal point but leave 2 zeros after the decimal point if all digits after the decimal point are zeros and 1 zero after the first non-zero digit following the decimal point if the remaining digits are also zeros? Examples:
123.000000 > 123.00
123.012345 > 123.012345
123.100000 > 123.10
123.123456 > 123.123456
123.120000 > 123.12
Code: Select all
for k, v in [123.000000, 123.012345, 123.100000, 123.123456, 123.120000]
MsgBox % RemoveOver2TrailingZero(v)
RemoveOver2TrailingZero(x)
{
return RegExReplace(x, "(^\d*.\d\d\d*?)(0*)$", "$1")
}
Return to “Scripts and Functions (v1)”
Users browsing this forum: KruschenZ and 178 guests