ObjFW  Diff

Differences From Artifact [2866f4968c]:

To Artifact [a189f6857c]:


1036
1037
1038
1039
1040
1041
1042

1043
1044
1045

1046
1047
1048
1049


1050
1051



1052


1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067

1068
1069
1070
1071
1072
1073
1074


1075

1076

1077
1078



1079





1080

1081

1082
1083
1084
1085
1086
1087
1088

		return OF_ORDERED_SAME;
	}
}

- (uint32_t)hash
{

	uint32_t hash;
	uint8_t i;


	switch (type) {
	case OF_NUMBER_FLOAT:;
		union {
			float f;


			uint8_t b[sizeof(float)];
		} f;






		f.f = OF_BSWAP_FLOAT_IF_LE(value.float_);

		OF_HASH_INIT(hash);

		for (i = 0; i < sizeof(float); i++)
			OF_HASH_ADD(hash, f.b[i]);

		OF_HASH_FINALIZE(hash);

		return hash;
	case OF_NUMBER_DOUBLE:;
		union {
			double d;
			uint8_t b[sizeof(double)];
		} d;


		d.d = OF_BSWAP_DOUBLE_IF_LE(value.double_);

		OF_HASH_INIT(hash);

		for (i = 0; i < sizeof(double); i++)
			OF_HASH_ADD(hash, d.b[i]);




		OF_HASH_FINALIZE(hash);


		return hash;



	default:





		return [self uInt32Value];

	}

}

- (OFNumber*)numberByAddingNumber: (OFNumber*)num
{
	CALCULATE(+, num)
}








>

<

>
|
|
|
|
>
>
|
|
>
>
>
|
>
>
|
|
<
|
<
<

|

<
|




>

|
<
<



>
>

>
|
>
|
|
>
>
>
|
>
>
>
>
>
|
>
|
>







1036
1037
1038
1039
1040
1041
1042
1043
1044

1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062

1063


1064
1065
1066

1067
1068
1069
1070
1071
1072
1073
1074


1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105

		return OF_ORDERED_SAME;
	}
}

- (uint32_t)hash
{
	of_number_type_t type_ = type;
	uint32_t hash;


	/* Do we really need signed to represent this number? */
	if (type_ & OF_NUMBER_SIGNED && [self intMaxValue] >= 0)
		type_ &= ~OF_NUMBER_SIGNED;

	/* Do we really need floating point to represent this number? */
	if (type_ & OF_NUMBER_FLOAT) {
		double v = [self doubleValue];

		if (v < 0) {
			if (v == [self intMaxValue]) {
				type_ &= ~OF_NUMBER_FLOAT;
				type_ |= OF_NUMBER_SIGNED;
			}
		} else {
			if (v == [self uIntMaxValue])
				type_ &= ~OF_NUMBER_FLOAT;
		}

	}



	OF_HASH_INIT(hash);


	if (type_ & OF_NUMBER_FLOAT) {
		union {
			double d;
			uint8_t b[sizeof(double)];
		} d;
		uint_fast8_t i;

		d.d = OF_BSWAP_DOUBLE_IF_BE([self doubleValue]);



		for (i = 0; i < sizeof(double); i++)
			OF_HASH_ADD(hash, d.b[i]);
	} else if (type_ & OF_NUMBER_SIGNED) {
		intmax_t v = [self intMaxValue] * -1;

		while (v != 0) {
			OF_HASH_ADD(hash, v & 0xFF);
			v >>= 8;
		}

		OF_HASH_ADD(hash, 1);
	} else {
		uintmax_t v = [self uIntMaxValue];

		while (v != 0) {
			OF_HASH_ADD(hash, v & 0xFF);
			v >>= 8;
		}
	}

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFNumber*)numberByAddingNumber: (OFNumber*)num
{
	CALCULATE(+, num)
}