Fix behavior of plural with float arguments that can be integers (e.g, 1.0)

PiperOrigin-RevId: 281172075
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5fcade6..21c928b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,9 @@
    with optional arguments (variables/placeholders). Common data types will
    be formatted properly for the given locale. It handles both pluralization
    and gender. Think of it as "internationalization aware printf."
+ * Change plural behavior with floating point howMany argument so that doubles
+   that are equal to integers print the same as the integer 1. That is, '1
+   dollar', rather than '1.0 dollars'.
 
 ## 0.16.0
  * Fix 'k' formatting (1 to 24 hours) which incorrectly showed 0 to 23.
diff --git a/lib/intl.dart b/lib/intl.dart
index f4120c7..7116d5f 100644
--- a/lib/intl.dart
+++ b/lib/intl.dart
@@ -364,6 +364,13 @@
     if (howMany == null) {
       throw ArgumentError('The howMany argument to plural cannot be null');
     }
+    // If we haven't specified precision and we have a float that is an integer
+    // value, turn it into an integer. This gives us the behavior that 1.0 and 1
+    // produce the same output, e.g. 1 dollar.
+    var truncated = howMany.truncate();
+    if (precision == null && truncated == howMany) {
+      howMany = truncated;
+    }
 
     // This is for backward compatibility.
     // We interpret the presence of [precision] parameter as an "opt-in" to
diff --git a/test/message_format_test.dart b/test/message_format_test.dart
index ec1ca22..03a2b47 100644
--- a/test/message_format_test.dart
+++ b/test/message_format_test.dart
@@ -330,8 +330,8 @@
     expect(fmt.format({'SOME_NUM': 17}), '17 many');
     expect(fmt.format({'SOME_NUM': 100}), '100 many');
     expect(fmt.format({'SOME_NUM': 1.4}), '1,4 other');
-    expect(fmt.format({'SOME_NUM': '10.0'}), '10 other');
-    expect(fmt.format({'SOME_NUM': '100.00'}), '100 other');
+    expect(fmt.format({'SOME_NUM': '10.0'}), '10 many');
+    expect(fmt.format({'SOME_NUM': '100.00'}), '100 many');
   });
 
   test('testPluralWithIgnorePound', () {
diff --git a/test/plural_test.dart b/test/plural_test.dart
index 5118064..f3da8ba 100644
--- a/test/plural_test.dart
+++ b/test/plural_test.dart
@@ -217,6 +217,9 @@
     test(lines[i], () {
       var number = int.parse(lines[i].split(':').first);
       expect(pluralFunction(number, locale), lines[i]);
+      var float = number.toDouble();
+      var lineWithFloat = lines[i].replaceFirst('$number', '$float');
+      expect(pluralFunction(float, locale), lineWithFloat);
     });
   }
 }