Permalink
Browse files

Add unary minus as operator supported by verireal.

  • Loading branch information...
1 parent 8d31023 commit fbfc796647b34cb6c451f21f83b2d379e9ca49fb steve committed Jun 4, 2004
Showing with 21 additions and 4 deletions.
  1. +12 −2 verireal.cc
  2. +9 −2 verireal.h
View
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 1999-2004 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: verireal.cc,v 1.14 2003/03/07 06:10:13 steve Exp $"
+#ident "$Id: verireal.cc,v 1.15 2004/06/04 23:33:51 steve Exp $"
#endif
# include "config.h"
@@ -117,6 +117,13 @@ verireal operator% (const verireal&l, const verinum&r)
return res;
}
+verireal operator- (const verireal&l)
+{
+ verireal res;
+ res.value_ = - l.value_;
+ return res;
+}
+
ostream& operator<< (ostream&out, const verireal&v)
{
out << v.value_;
@@ -125,6 +132,9 @@ ostream& operator<< (ostream&out, const verireal&v)
/*
* $Log: verireal.cc,v $
+ * Revision 1.15 2004/06/04 23:33:51 steve
+ * Add unary minus as operator supported by verireal.
+ *
* Revision 1.14 2003/03/07 06:10:13 steve
* Use strtod to convert text to doubles.
*
View
@@ -1,7 +1,7 @@
#ifndef __verireal_H
#define __verireal_H
/*
- * Copyright (c) 1999 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 1999-2004 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: verireal.h,v 1.9 2003/02/07 06:13:44 steve Exp $"
+#ident "$Id: verireal.h,v 1.10 2004/06/04 23:33:51 steve Exp $"
#endif
#ifdef HAVE_IOSFWD
@@ -46,6 +46,9 @@ class verireal {
friend verireal operator% (const verireal&, const verireal&);
friend verireal operator% (const verireal&, const verinum&);
+ // Unary minus.
+ friend verireal operator- (const verireal&);
+
public:
explicit verireal();
explicit verireal(const char*text);
@@ -71,9 +74,13 @@ extern verireal operator/ (const verireal&, const verireal&);
extern verireal operator/ (const verireal&, const verinum&);
extern verireal operator% (const verireal&, const verireal&);
extern verireal operator% (const verireal&, const verinum&);
+extern verireal operator- (const verireal&);
/*
* $Log: verireal.h,v $
+ * Revision 1.10 2004/06/04 23:33:51 steve
+ * Add unary minus as operator supported by verireal.
+ *
* Revision 1.9 2003/02/07 06:13:44 steve
* Store real values as native double.
*

0 comments on commit fbfc796

Please sign in to comment.