Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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!