说我要减去:0000 0000 - ( - 1)
那是:(两个补充)
0000 0000
- 1111 1111
---------
= ???? ????
Run Code Online (Sandbox Code Playgroud)
什么事情会发生,我的大脑现在真的和我在一起,它之前完全没问题,我认为它的溢出让我搞砸了,有人可以请一些清关吗:)?
我试图从for循环内的字符串中删除一个空格.我能够让它为添加空间而工作,但删除不起作用.
这是我的代码:
letterHeight = 10
def nLetter():
x = 0
diagonal = ""
vertical = " "
while x < letterHeight:
print "*"+diagonal+"*"+vertical+"*"
diagonal += " "
vertical -= " "
x += 1
nLetter()
Run Code Online (Sandbox Code Playgroud)
错误: TypeError: unsupported operand type(s) for -=: 'str' and 'str'
有没有办法用Objective-C减去两个或更多NSUInteger值?
这是我的代码
__block NSUInteger *removedElementsCount = 0;
__block BOOL lastIsSuperElement = NO;
// Get the elements not collapsed
[_elements enumerateObjectsUsingBlock:^(id __nonnull obj, NSUInteger idx, BOOL * __nonnull stop) {
if (_isHidingSubElementsBlock(obj)){
//_collapseSubCellsAtIndexPathBlock(idx+_elementsOffset);
[elementToRemove addObject:(Task *)obj];
lastIsSuperElement = YES;
[indexPathToRemove addObject:[NSIndexPath indexPathForRow:(idx-removedElementsCount) inSection:0]];
removedElementsCount = 0;
} else if (lastIsSuperElement){
removedElementsCount++;
lastIsSuperElement = NO;
}
}];
Run Code Online (Sandbox Code Playgroud)
当我尝试使用idx-removedElementsCount创建新的NSIndexPath时,出现以下错误:
HTReorderTableCells.m:231:75: Invalid operands to binary expression ('NSUInteger' (aka 'unsigned int') and 'NSUInteger *' (aka 'unsigned int *'))
Run Code Online (Sandbox Code Playgroud)
我找了一个解决方案,但我没找到任何东西.
这是在C.我正在学习C,这是一个来自课堂幻灯片的例子.
int main(int argc, char *argv[]) {
int a = 5, b = 10, c;
int *p = &a, *q = &b;
c = p - q;
printf("%d", c);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我运行时的输出是3,我不明白为什么.似乎因为它正在使用&它将减去内存地址,输出将是-5的内存地址.
我想找到两个数字(正整数)之间的差异而不返回任何正号或负号.
就像
Diff(2,5) => 3
Diff(5,2) => 3.
Run Code Online (Sandbox Code Playgroud)
并不是
(2 - 5) => -3
Run Code Online (Sandbox Code Playgroud) 我正在编写一个代码,其中每半秒进行一次测量,需要从初始值中减去最终达到0.两个值都是浮点数.初始值为140 000 000,测量范围为0.320000001至0.389999999.
float batt = 140000000.00; //capacity 140M units
float subtr;
/.../
while(1){
batt = float(batt - subtr);
/.../
}
Run Code Online (Sandbox Code Playgroud)
所以基本上我需要它从148,000,000.00的每个循环减去0.3xxxxxxxx,但似乎有一个大小问题所以当我调试它时我仍然每次得到148M.
我尝试使用1000x较小的battbatt值,148 000,并将测量值从0.3xxxxxxxx转换为0.0003xxxxxxxx.调试代码时,148000 - 0.000300005049(测量值)给出147999.469,这是预期结果(147,999.999,699)的.530699.
似乎浮动对我的需求不够准确,我应该将我的值转换为其他类型,还是有其他方法可以获得准确的结果?正在考虑将测量值转换为没有小数的值,但这也不会起作用,因为初始值对于float(148*10 ^ 15)来说太大了.当使用140,000,000.00时,我希望得到三位小数(.xxx)的准确度,并相应地使用140,000.00准确度的六位小数(.xxx,xxx).
我需要帮助在 PHP 中减去 2 次。
例子:
$date1 = 02:40;
$date2 = 00:00;
$finaldate = $date1 - $date2;
Run Code Online (Sandbox Code Playgroud)
正确答案是 21:20。