Search Unity

How to calculate using different types of numerical values(int and float)? Not convert int to float

Discussion in 'Scripting' started by Lesnikus, Mar 24, 2018.

  1. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    How to calculate using different types of numerical values?? I want to subtract value of type float from the large int value. Convert int to float is impossible, because there are very large int!
    For example:

    int xInt = 2000000000;
    float xFlo = 4.23;

    Calculate: xFlo - xInt. Result:

    xInt = 1999999995
    xFlo = 0.77
     
  2. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Have you considered using doubles?
     
  3. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    Brilliantly simple. You saved me!