So I have been getting null results and null reference errors from this script
Null reference: object reference not set to an instance of an object
I have tried trouble shooting this, but basically I am trying to create a system that allows me to display a huge number to players, while being able to make a code that can run it that goes larger than doubles, but is probably a bit messier… point is, how the heck do I put my number system script and class to use?
public class Number_System : MonoBehaviour
{
public static Number_System instance;
public double exponent;
public double mantissa;
// instantiaziation, and enabling use
private void Awake()
{
instance = this;
}
// the maths of the number systems, currently supports addition, subrtaction, multiplication and division, but not any higher powers, and division
public void Number_subtraction(Number_System x, Number_System y)
{
if ((y.exponent- x.exponent) > - 4)
{
x.mantissa -= y.mantissa *System.Math.Pow(10, y.exponent - x.exponent);
}
}
public void Number_addition(Number_System x, Number_System y)
{
if ((y.exponent - x.exponent) > -4)
{
x.mantissa += y.mantissa * System.Math.Pow(10, y.exponent - x.exponent);
}
}
public void Number_multiplication(Number_System x, Number_System y)
{
x.exponent += y.exponent;
x.mantissa *= y.mantissa;
}
public void Number_division(Number_System x, Number_System y)
{
x.exponent -= y.exponent;
x.mantissa /= y.mantissa;
}
public void Update()
{
if (mantissa >= 10)
{
mantissa= mantissa/10;
exponent = +1;
}
if (mantissa < 1 && mantissa > 0 )
{
mantissa = mantissa*10;
exponent = -1;
}
if (mantissa < 0 && exponent >= 0)
{
mantissa = mantissa / -1;
}
}
}
public class Data_system
{
public Number_System color;
public Data_system()
{
color.mantissa = 0;
color.exponent = 0;
}
}
public class Base_game : MonoBehaviour
{
public Data_system data;
// this code is setting up the instance to be analyzed by other scripts
public static Base_game instance;
private void Awake()
{
instance = this;
}
}
public class Text_System : MonoBehaviour
{
public Data_system data;
public string color;
void Update()
{
data = Base_game.instance.data;
Debug.Log(data);
}
}