fix misformatting of floats with leading zeros
diff --git a/black.py b/black.py
index c899bde36db..d81c3548703 100644
--- a/black.py
+++ b/black.py
@@ -2564,7 +2564,9 @@ def format_int_string(text: str, allow_underscores: bool) -> str:
         # No underscores for numbers <= 6 digits long.
         return text
 
-    return format(int(text), "3_")
+    # Avoid removing leading zeros, which are important if we're formatting
+    # part of a number like "0.001".
+    return format(int("1" + text), "3_")[1:].lstrip("_")
 
 
 def normalize_invisible_parens(node: Node, parens_after: Set[str]) -> None:
diff --git a/tests/data/numeric_literals.py b/tests/data/numeric_literals.py
index 8999b9d4038..2dc64c75c8b 100644
--- a/tests/data/numeric_literals.py
+++ b/tests/data/numeric_literals.py
@@ -14,6 +14,7 @@
 x = 0XB1ACC
 x = 0B1011
 x = 0O777
+x = 0.000000006
 
 # output
 
@@ -34,3 +35,4 @@
 x = 0xb1acc
 x = 0b1011
 x = 0o777
+x = 0.000_000_006

This is a bug in my previous code: it ended up turning "0.06" into "0.6".

The solution in this diff is a bit hacky, but it has the virtue of being correct, unlike the previous code.

It might be worth thinking about this part of the style some more: Should we even put underscores in the part of floats behind the decimal point? If so, should we count the groups from the end, like we do now, or from the beginning? (The difference between `0.12_345_678` and `0.123_456_78`.)