[Groonga-commit] groonga/grnxx at 979f2a1 [master] Rename Float::value() to raw(). (#116)

Back to archive index

susumu.yata null+****@clear*****
Tue Dec 16 10:45:46 JST 2014


susumu.yata	2014-11-25 12:49:26 +0900 (Tue, 25 Nov 2014)

  New Revision: 979f2a18fd46bacc910e5eec8c0c32adedb6d92f
  https://github.com/groonga/grnxx/commit/979f2a18fd46bacc910e5eec8c0c32adedb6d92f

  Message:
    Rename Float::value() to raw(). (#116)

  Modified files:
    include/grnxx/data_types/scalar/float.hpp
    include/grnxx/data_types/scalar/geo_point.hpp
    include/grnxx/data_types/typecast.hpp
    include/grnxx/data_types/vector/float.hpp

  Modified: include/grnxx/data_types/scalar/float.hpp (+41 -41)
===================================================================
--- include/grnxx/data_types/scalar/float.hpp    2014-11-25 12:44:39 +0900 (e7d7a1f)
+++ include/grnxx/data_types/scalar/float.hpp    2014-11-25 12:49:26 +0900 (7b2aeb1)
@@ -22,27 +22,27 @@ class Float {
 
   // TODO: +/-0.0 and NaN may be normalized.
   //       -0.0 to +0.0 and various NaN to the quiet NaN.
-  explicit constexpr Float(double value) : value_(value) {}
-  explicit constexpr Float(NA) : value_(na_value()) {}
+  explicit constexpr Float(double raw) : raw_(raw) {}
+  explicit constexpr Float(NA) : raw_(raw_na()) {}
 
-  constexpr double value() const {
-    return value_;
+  constexpr double raw() const {
+    return raw_;
   }
 
   constexpr bool is_min() const {
-    return value_ == min_value();
+    return raw_ == raw_min();
   }
   constexpr bool is_max() const {
-    return value_ == max_value();
+    return raw_ == raw_max();
   }
   constexpr bool is_finite() const {
-    return std::isfinite(value_);
+    return std::isfinite(raw_);
   }
   constexpr bool is_infinite() const {
-    return std::isinf(value_);
+    return std::isinf(raw_);
   }
   constexpr bool is_na() const {
-    return std::isnan(value_);
+    return std::isnan(raw_);
   }
 
   // -- Unary operators --
@@ -51,7 +51,7 @@ class Float {
     return *this;
   }
   constexpr Float operator-() const {
-    return Float(-value_);
+    return Float(-raw_);
   }
 
   // -- Binary operators --
@@ -59,73 +59,73 @@ class Float {
   // -- Arithmetic operators --
 
   constexpr Float operator+(Float rhs) const {
-    return Float(value_ + rhs.value_);
+    return Float(raw_ + rhs.raw_);
   }
   constexpr Float operator-(Float rhs) const {
-    return Float(value_ - rhs.value_);
+    return Float(raw_ - rhs.raw_);
   }
   constexpr Float operator*(Float rhs) const {
-    return Float(value_ * rhs.value_);
+    return Float(raw_ * rhs.raw_);
   };
   constexpr Float operator/(Float rhs) const {
-    return Float(value_ / rhs.value_);
+    return Float(raw_ / rhs.raw_);
   }
   Float operator%(Float rhs) const {
-    return Float(std::fmod(value_, rhs.value_));
+    return Float(std::fmod(raw_, rhs.raw_));
   }
 
   Float &operator+=(Float rhs) & {
-    value_ += rhs.value_;
+    raw_ += rhs.raw_;
     return *this;
   }
   Float &operator-=(Float rhs) & {
-    value_ -= rhs.value_;
+    raw_ -= rhs.raw_;
     return *this;
   }
   Float &operator*=(Float rhs) & {
-    value_ *= rhs.value_;
+    raw_ *= rhs.raw_;
     return *this;
   }
   Float &operator/=(Float rhs) &{
-    value_ /= rhs.value_;
+    raw_ /= rhs.raw_;
     return *this;
   }
   Float &operator%=(Float rhs) &{
-    value_ = std::fmod(value_, rhs.value_);
+    raw_ = std::fmod(raw_, rhs.raw_);
     return *this;
   }
 
   // -- Comparison operators --
 
   constexpr Bool operator==(Float rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ == rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ == rhs.raw_);
   }
   constexpr Bool operator!=(Float rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ != rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ != rhs.raw_);
   }
   constexpr Bool operator<(Float rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ < rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ < rhs.raw_);
   }
   constexpr Bool operator>(Float rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ > rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ > rhs.raw_);
   }
   constexpr Bool operator<=(Float rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ <= rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ <= rhs.raw_);
   }
   constexpr Bool operator>=(Float rhs) const {
-    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(value_ >= rhs.value_);
+    return (is_na() || rhs.is_na()) ? Bool::na() : Bool(raw_ >= rhs.raw_);
   }
 
   constexpr bool match(Float rhs) const {
-    return (is_na() && rhs.is_na()) || (value_ == rhs.value_);
+    return (is_na() && rhs.is_na()) || (raw_ == rhs.raw_);
   }
   constexpr bool unmatch(Float rhs) const {
-    return !(is_na() && rhs.is_na()) && (value_ != rhs.value_);
+    return !(is_na() && rhs.is_na()) && (raw_ != rhs.raw_);
   }
 
   // Return the next representable toward "to".
   Float next_toward(Float to) const {
-    return Float(std::nextafter(value_, to.value_));
+    return Float(std::nextafter(raw_, to.raw_));
   }
 
   // -- Typecast (grnxx/data_types/typecast.hpp) --
@@ -137,45 +137,45 @@ class Float {
   }
 
   static constexpr Float min() {
-    return Float(min_value());
+    return Float(raw_min());
   }
   static constexpr Float max() {
-    return Float(max_value());
+    return Float(raw_max());
   }
   static constexpr Float normal_min() {
-    return Float(normal_min_value());
+    return Float(raw_normal_min());
   }
   static constexpr Float subnormal_min() {
-    return Float(subnormal_min_value());
+    return Float(raw_subnormal_min());
   }
   static constexpr Float infinity() {
-    return Float(infinity_value());
+    return Float(raw_infinity());
   }
   static constexpr Float na() {
     return Float(NA());
   }
 
-  static constexpr double min_value() {
+  static constexpr double raw_min() {
     return std::numeric_limits<double>::lowest();
   }
-  static constexpr double max_value() {
+  static constexpr double raw_max() {
     return std::numeric_limits<double>::max();
   }
-  static constexpr double normal_min_value() {
+  static constexpr double raw_normal_min() {
     return std::numeric_limits<double>::min();
   }
-  static constexpr double subnormal_min_value() {
+  static constexpr double raw_subnormal_min() {
     return std::numeric_limits<double>::denorm_min();
   }
-  static constexpr double infinity_value() {
+  static constexpr double raw_infinity() {
     return std::numeric_limits<double>::infinity();
   }
-  static constexpr double na_value() {
+  static constexpr double raw_na() {
     return std::numeric_limits<double>::quiet_NaN();
   }
 
  private:
-  double value_;
+  double raw_;
 };
 
 }  // namespace grnxx

  Modified: include/grnxx/data_types/scalar/geo_point.hpp (+7 -7)
===================================================================
--- include/grnxx/data_types/scalar/geo_point.hpp    2014-11-25 12:44:39 +0900 (ad4ecce)
+++ include/grnxx/data_types/scalar/geo_point.hpp    2014-11-25 12:49:26 +0900 (7966c63)
@@ -22,7 +22,7 @@ class GeoPoint {
   GeoPoint(const GeoPoint &) = default;
   GeoPoint &operator=(const GeoPoint &) = default;
 
-  // NOTE: The following implementation assumes that Int::na()::value() returns
+  // NOTE: The following implementation assumes that Int::na()::raw() returns
   //       a value less than min_latitude/longitude() or greater than
   //       max_latitude/longitude().
   GeoPoint(Int latitude_in_milliseconds, Int longitude_in_milliseconds)
@@ -48,12 +48,12 @@ class GeoPoint {
       : latitude_(),
         longitude_() {
     // N/A (NaN) is rejected due to LOGICAL_AND.
-    if ((latitude_in_degrees.value() >= -90.0) &&
-        (latitude_in_degrees.value() <= 90.0) &&
-        (longitude_in_degrees.value() >= -180.0) &&
-        (longitude_in_degrees.value() <= 180.0)) {
-      int64_t latitude = latitude_in_degrees.value() * 60 * 60 * 1000;
-      int64_t longitude = longitude_in_degrees.value() * 60 * 60 * 1000;
+    if ((latitude_in_degrees.raw() >= -90.0) &&
+        (latitude_in_degrees.raw() <= 90.0) &&
+        (longitude_in_degrees.raw() >= -180.0) &&
+        (longitude_in_degrees.raw() <= 180.0)) {
+      int64_t latitude = latitude_in_degrees.raw() * 60 * 60 * 1000;
+      int64_t longitude = longitude_in_degrees.raw() * 60 * 60 * 1000;
       if ((latitude == min_latitude()) || (latitude == max_latitude())) {
         longitude = 0;
       } else if (longitude == max_longitude()) {

  Modified: include/grnxx/data_types/typecast.hpp (+1 -1)
===================================================================
--- include/grnxx/data_types/typecast.hpp    2014-11-25 12:44:39 +0900 (f94e012)
+++ include/grnxx/data_types/typecast.hpp    2014-11-25 12:49:26 +0900 (c5cd1e1)
@@ -17,7 +17,7 @@ inline constexpr Float Int::to_float() const {
 //       results in the value associated with N/A (0x80...).
 //       The CVTTSD2SI instruction of x86_64 works as mentioned.
 inline constexpr Int Float::to_int() const {
-  return Int(static_cast<int64_t>(value_));
+  return Int(static_cast<int64_t>(raw_));
 }
 
 }  // namespace grnxx

  Modified: include/grnxx/data_types/vector/float.hpp (+2 -2)
===================================================================
--- include/grnxx/data_types/vector/float.hpp    2014-11-25 12:44:39 +0900 (74e0ac7)
+++ include/grnxx/data_types/vector/float.hpp    2014-11-25 12:49:26 +0900 (8e7edb8)
@@ -54,7 +54,7 @@ class Vector<Float> {
     if (has_equal_size.is_true()) {
       size_t size = size_.raw();
       for (size_t i = 0; i < size; ++i) {
-        if ((data_[i].value() != rhs.data_[i].value()) &&
+        if ((data_[i].raw() != rhs.data_[i].raw()) &&
             (!data_[i].is_na() || !rhs.data_[i].is_na())) {
           return Bool(false);
         }
@@ -68,7 +68,7 @@ class Vector<Float> {
     if (has_not_equal_size.is_false()) {
       size_t size = size_.raw();
       for (size_t i = 0; i < size; ++i) {
-        if ((data_[i].value() != rhs.data_[i].value()) &&
+        if ((data_[i].raw() != rhs.data_[i].raw()) &&
             (!data_[i].is_na() || !rhs.data_[i].is_na())) {
           return Bool(true);
         }
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-commit mailing list
Back to archive index