本文介绍了如何在Delphi中将正数转换为负数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用Delphi将正整数转换为负整数?我知道您可以使用 ABS(int)
将负数转换为正数,但是我需要它将正数转换为负数。
。如果您的变量>可以使
0然后
yourvariable:= -yourvariable;
How do I convert a positive Integer to a negative with Delphi? I know you could use ABS(int)
to convert a negative to a positive, but I need it to convert positive to negative.
解决方案
from what I know there is no function for that. you can make
if yourvariable > 0 then
yourvariable := -yourvariable;
这篇关于如何在Delphi中将正数转换为负数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!