using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

float f1 = 0.1f - 0.2f;

float f2 = 43.1f - 43.2f;

double d3 = 0.1 - 0.2;

print("0.1-0.2=" + f1);

print ("43.1f-43.2f = " + f2);

if(f1 == f2)

{

print("Equal");

}

else{

print ("Not Equal");

}

}

// Update is called once per frame

void Update () {

}

}

실수형은 실수를 많이 한다.


using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

decimal a = 0.1m - 0.2m;

decimal b = 43.1m - 43.2m;

print (" 0.1m - 0.2m = " + a);

print (" 43.1m - 43.2m = " + b);

if(a == b)

print ("equal");

else

print ("Not Equal");

}

// Update is called once per frame

void Update () {

}

}
decimal은 오차가 없다




'Computer Language > 유니티' 카테고리의 다른 글

이스케이프 문자  (0) 2014.03.31
문자형  (0) 2014.03.31
자료형(실수)  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31

void Start () {

Debug.Log("float Min = " + float.MinValue + ", Max = " + float.MaxValue);

Debug.Log ("double Min = " + double.MaxValue + ", Max = " + double.MaxValue);

Debug.Log ("decimial Min = " + decimal.MaxValue + ",Max = " + decimal.MaxValue);

}


decimal 돈 계산시 사용, 29자리. 속도가 느리다

float double 계산이 정확하지 않음. 그나마 더블이 정확한데 오차가 많다.

'Computer Language > 유니티' 카테고리의 다른 글

문자형  (0) 2014.03.31
실수를 많이 해서 실수형.  (0) 2014.03.31
자료형(정수)  (0) 2014.03.31
왼쪽 오른쪽 이동 그리고 정지  (0) 2014.03.31
탱크 이동  (0) 2014.03.28

using UnityEngine;

using System.Collections;


public class Chap3 : MonoBehaviour {


// Use this for initialization

void Start () {

PrintTableData();

PrintSystemTableData();

}

// Update is called once per frame

void Update () {

}

void PrintSystemTableData(){

Debug.Log("System.Sbyte Min = "+ System.SByte.MinValue + "  Max = " + System.SByte.MaxValue);

Debug.Log("System.Byte Min = "+ System.Byte.MinValue + "  Max = " + System.Byte.MaxValue);

Debug.Log("System.Int16 Min = "+ System.Int16.MinValue + " Max = " + System.Int16.MaxValue);

Debug.Log("System.UInt16 Min = "+ System.UInt16.MinValue + "  Max = " + System.UInt16.MaxValue);

Debug.Log("System.int32 Min = "+ System.Int32.MinValue + "  Max = " + System.Int32.MaxValue);

Debug.Log("System.UInt32 Min = "+ System.UInt32.MinValue + "  Max = " + System.UInt32.MaxValue);

Debug.Log("System.Int64 Min = "+ System.Int64.MinValue + " Max = " + System.Int64.MaxValue);

Debug.Log("System.UInt64 Min = "+ System.UInt64.MinValue + "  Max = " + System.UInt64.MaxValue);

}

void PrintTableData(){

Debug.Log("sbyte Min = "+ sbyte.MinValue + " sbyte Max = " + sbyte.MaxValue);

Debug.Log ("byte Min = " + byte.MinValue + " byte Max = " + byte.MaxValue);

Debug.Log("short Min = "+ short.MinValue + " short Max = " + short.MaxValue);

Debug.Log("ushort Min = " + ushort.MinValue + " ushort Max = " + ushort.MaxValue);

Debug.Log("int Min = "+ int.MinValue + " int Max = " + int.MaxValue);

Debug.Log("usint Min = " + uint.MinValue + " uint Max = " + uint.MaxValue);

Debug.Log ("long Min = " + long.MinValue + " long Max = " + ulong.MaxValue);

Debug.Log("ulong Min = " + ulong.MinValue + " ulong max = " + ulong.MaxValue);

}

void PrintTableData2(){

Debug.Log("float Min = " + float.MinValue + ", Max = " + float.MaxValue);

Debug.Log ("double Min = " + double.MaxValue + ", Max = " + double.MaxValue);

Debug.Log ("decimial Min = " + decimal.MaxValue + ",Max = " + decimal.MaxValue);

}

}




+ Recent posts