Exemplo n.º 1
0
int main()
{
	bool isMinus = false;
	char input1[101], input2[101];
	int len1, len2;

	scanf("%s", input1);	scanf("%s", input2);
	len1 = strlen(input1),	len2 = strlen(input2);

	if (len2 > len1)
		isMinus = true;
	else if (len2 == len1)
	{
		int index = 0;
		while (index < len1)
		{
			if (input1[index] > input2[index])
				break;
			else if (input1[index] < input2[index])
			{
				isMinus = true;
				break;
			}
			index++;
			if (index == len1)
				printf("0\n");
		}		
	}

	for (int i = 0; i < len1; i++)
		input1[i] -= '0';
	for (int i = 0; i < len2; i++)
		input2[i] -= '0';


	if (isMinus)
	{
		printf("-");
		longSub(input2,input1,len2-1,len1-1);
	}
	else	
		longSub(input1,input2,len1-1,len2-1);

	return 0;
}
Exemplo n.º 2
0
extern "C" Box* sub_i64_i64(i64 lhs, i64 rhs) {
    i64 result;
    if (!__builtin_ssubl_overflow(lhs, rhs, &result))
        return boxInt(result);
    return longSub(boxLong(lhs), boxLong(rhs));
}