aboutsummaryrefslogtreecommitdiff
path: root/gcc/sreal.h
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2014-12-15 23:03:11 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2014-12-15 22:03:11 +0000
commit2bef63e105f0fb8f857ec72ce6f6322aa605fa1a (patch)
tree47e5dd490ff7e0e1fe6e3f4282b7c591b9d7503b /gcc/sreal.h
parent426bcc95cbaed399329579feb14f776d4c2e4525 (diff)
downloadgcc-2bef63e105f0fb8f857ec72ce6f6322aa605fa1a.zip
gcc-2bef63e105f0fb8f857ec72ce6f6322aa605fa1a.tar.gz
gcc-2bef63e105f0fb8f857ec72ce6f6322aa605fa1a.tar.bz2
sreal.h (to_double): New method.
* sreal.h (to_double): New method. (shift): Do not ICE on 0. * sreal.c: Include math.h (sreal::to_double): New. From-SVN: r218765
Diffstat (limited to 'gcc/sreal.h')
-rw-r--r--gcc/sreal.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/sreal.h b/gcc/sreal.h
index 730f49c..6314cea 100644
--- a/gcc/sreal.h
+++ b/gcc/sreal.h
@@ -46,6 +46,7 @@ public:
void dump (FILE *) const;
int64_t to_int () const;
+ double to_double () const;
sreal operator+ (const sreal &other) const;
sreal operator- (const sreal &other) const;
sreal operator* (const sreal &other) const;
@@ -83,12 +84,14 @@ public:
sreal shift (int s) const
{
+ /* Zero needs no shifting. */
+ if (!m_sig)
+ return *this;
gcc_checking_assert (s <= SREAL_BITS);
gcc_checking_assert (s >= -SREAL_BITS);
- /* Exponent should never be so large because shift_right is used only by
- sreal_add and sreal_sub ant thus the number cannot be shifted out from
- exponent range. */
+ /* Overflows/drop to 0 could be handled gracefully, but hopefully we do not
+ need to do so. */
gcc_checking_assert (m_exp + s <= SREAL_MAX_EXP);
gcc_checking_assert (m_exp + s >= -SREAL_MAX_EXP);