FloatingPoint.cpp 608 B

123456789101112131415161718192021
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. /* Implementations of FloatingPoint functions */
  6. #include "mozilla/FloatingPoint.h"
  7. namespace mozilla {
  8. bool
  9. IsFloat32Representable(double aFloat32)
  10. {
  11. float asFloat = static_cast<float>(aFloat32);
  12. double floatAsDouble = static_cast<double>(asFloat);
  13. return floatAsDouble == aFloat32;
  14. }
  15. } /* namespace mozilla */