Menu

Warning while conversation from double

Leviathan
2020-07-06
2020-07-07
  • Leviathan

    Leviathan - 2020-07-06

    Hi, I have warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data

    ~~~
    double a = 1.0;
    half b = 2.0_h;
    b = (half)a;
    ~~~

    internally half.hpp not using double->half conversation code for some reason.
    I wrote here because it is not allowed to create ticket.

     

    Last edit: Leviathan 2020-07-10
    • Christian Rau

      Christian Rau - 2020-07-07

      Hello,

      Yes, this is a shortcoming of half not offering conversion constructors for
      every possible builtin type, but only for float. So when converting a
      double to a half, it always takes the route over the implicit conversion to
      float first. This is somewhat intentional, but can cause some unwanted
      warnings. The only way around that is either using the explicit 'half_cast'
      or explicitly converting the double to float beforehand. But I'm
      reconsidering the layout of conversion constructors and assignment
      operators.

      Regards,

      Christian Rau

      Am Mo., 6. Juli 2020 um 14:13 Uhr schrieb Leviathan inferno2k@users.sourceforge.net:

      Hi, I have warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data

      ~~~
      double a = 1.0;
      half b = 2.0_h;
      b = (half)a;
      ~~~

      internally half.hpp not using double->half conversation code for some
      reason.
      I wrote here because it is allowed to create ticket.


      Warning while conversation from double


      Sent from sourceforge.net because you indicated interest in <
      https://sourceforge.net/p/half/discussion/general/>

      To unsubscribe from further messages, please visit <
      https://sourceforge.net/auth/subscriptions/>

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.