-2

When I try to declare a float variable with a very small value it changes the notation.

Global $interior = 0.00008972
MsgBox(4096, "1", $interior)
$file = FileOpen("Balance.txt", 2)
FileWrite($file, ""&$interior)
FileClose($file)

It shows and writes to file 8.972e-005 not 0.00008972.

BSMP
  • 4,596
  • 8
  • 33
  • 44
  • 1
    They are the same floating point value - just normalized. (use this to confirm: https://web2.0calc.com/) Output: guessing: If you want to display it in a particular format see: https://www.autoitscript.com/autoit3/docs/functions/StringFormat.htm ? – Ryan Vincent Apr 09 '17 at 23:01

1 Answers1

1

You can use StringFormat to specify the precision you want for the float value.

Global $interior = 0.00008972
$interior = StringFormat("%.8f", $interior)
MsgBox(4096, "1", $interior)
$file = FileOpen("Balance.txt", 2)
FileWrite($file, ""&$interior)
FileClose($file)
RoastDuck
  • 124
  • 2
  • 10