diff options
author | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-23 02:08:05 +0000 |
---|---|---|
committer | kenton@google.com <kenton@google.com@630680e5-0e50-0410-840e-4b1c322b438d> | 2009-12-23 02:08:05 +0000 |
commit | 46ed74e8d456d7d2a983c6c86e2c347d8a5b4843 (patch) | |
tree | 36f35ae5ee48b75cfaa3465fca1adb49fd9c0b26 /src | |
parent | d0047c43d955174d79a2df623dbb4007965252b5 (diff) | |
download | protobuf-46ed74e8d456d7d2a983c6c86e2c347d8a5b4843.tar.gz protobuf-46ed74e8d456d7d2a983c6c86e2c347d8a5b4843.tar.bz2 protobuf-46ed74e8d456d7d2a983c6c86e2c347d8a5b4843.zip |
Actually, that last revision can be simpler -- we don't need to parse strings at all, as simply entering 1e1000 as a float literal in Python will be evaluated as infinity.
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/python/python_generator.cc | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/google/protobuf/compiler/python/python_generator.cc b/src/google/protobuf/compiler/python/python_generator.cc index 2f7d0981..fae83a37 100644 --- a/src/google/protobuf/compiler/python/python_generator.cc +++ b/src/google/protobuf/compiler/python/python_generator.cc @@ -169,14 +169,14 @@ string StringifyDefaultValue(const FieldDescriptor& field) { double value = field.default_value_double(); if (value == numeric_limits<double>::infinity()) { // Python pre-2.6 on Windows does not parse "inf" correctly. However, - // parsing a number that is too big for a double will return infinity. - return "float('1e10000')"; + // a numeric literal that is too big for a double will become infinity. + return "1e10000"; } else if (value == -numeric_limits<double>::infinity()) { // See above. - return "float('-1e10000')"; + return "-1e10000"; } else if (value != value) { // infinity * 0 = nan - return "(float('1e10000') * 0)"; + return "(1e10000 * 0)"; } else { return SimpleDtoa(value); } @@ -185,14 +185,14 @@ string StringifyDefaultValue(const FieldDescriptor& field) { float value = field.default_value_float(); if (value == numeric_limits<float>::infinity()) { // Python pre-2.6 on Windows does not parse "inf" correctly. However, - // parsing a number that is too big for a double will return infinity. - return "float('1e10000')"; + // a numeric literal that is too big for a double will become infinity. + return "1e10000"; } else if (value == -numeric_limits<float>::infinity()) { // See above. - return "float('-1e10000')"; + return "-1e10000"; } else if (value != value) { // infinity - infinity = nan - return "(float('1e10000') - float('1e10000'))"; + return "(1e10000 * 0)"; } else { return SimpleFtoa(value); } |