Java数学函数将正int转换为负数,负转换为正数? [英] Java math function to convert positive int to negative and negative to positive?

查看:5520
本文介绍了Java数学函数将正int转换为负数,负转换为正数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有Java函数将正int转换为负数而负数int转换为正数?

Is there a Java function to convert a positive int to a negative one and a negative int to a positive one?

我正在寻找 reverse 执行此转换的功能:

I'm looking for a reverse function to perform this conversion:

-5  ->  5
 5  -> -5


推荐答案

x怎么样? * = -1; ?你真的想要一个库函数吗?

What about x *= -1; ? Do you really want a library function for this?

这篇关于Java数学函数将正int转换为负数,负转换为正数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆