如何在C ++中制作16 BYE数据类型? [英] How to Make a 16 bye data type in C++?
问题描述
如何使16字节数据时间可以执行以下操作:
添加
减法
乘法
DIVISION
how we can make a 16 byte data time with which we can perform following operations:
ADDITION
SUBTRACTION
MULTIPLICATION
DIVISION
推荐答案
16字节
真的是16个字节吗?您确定不是16位位(有很大的不同)吗?
如果它是16个字节,那么您将需要创建一个类并覆盖+,-,/和*运算符(在Google上搜索运算符重载).
如果它是16位,则可以使用缩写.
Is it really 16 bytes ? Are you sure it is not 16 bits (which makes a huge difference) ?
If it is 16 bytes, then you will need to create a class and override the +, -, / and * operators (search on google for operators overloading).
If it is 16 bits, then you can use a short.
假设数据类型为integer
,则可以对执行所列操作的四个函数进行编码(例如,对两个),毕竟,您可以手工计算非常大的数字(换句话说,您只需考虑进位").
Assuming your data typeinteger
, you may code yourself the four functions performing the listed operations (for instance on two__int64
), after all, by hand, you are able to compute operations on very big numbers (in other words you have just to consider ''carry'').
创建一个类并使用两个8字节整数或四个4字节整数封装16个字节.
重载+
,-
,*
和/
运算符,并在其中编写自己的逻辑以分别执行加法,减法,乘法和除法.
Create a class and encapsulate the 16 bytes either using two 8 byte integers or four 4 byte integers.
Overload the+
,-
,*
and/
operators and write your own logic in them to perform addition, subtraction, multiplication and division respectively.
这篇关于如何在C ++中制作16 BYE数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!