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

Double Math Determinism

Discussion in 'Scripting' started by jpthek9, Feb 9, 2015.

  1. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Will calculations on different platforms be precise enough to be used in a lockstep RTS game if the square root and trigonometry functions will be used extensively for games of up to 3 hours in length?
     
    Last edited: Feb 9, 2015
  2. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,077
    Can't say for sure, but I would be surprised if they did. Maybe someone else knows?
     
  3. Limyc

    Limyc

    Joined:
    Jan 27, 2013
    Posts:
    29
    No, they will not. AFAIK, floating-point determinism is not possible in C#, and it is extremely difficult to pull off in C/C++. This article will help explain why: link

    You'll either need to use fixed-point math (slow and limiting) or find a different solution. You might look at Planetary Annihilation's approach to the problem (Chrono Cam tech).
     
    Todd-Wasson likes this.