---
title: "c语言中-x的实现原理"
author: "hotcharm"
date: "2009-07-25T12:21:00Z"
tags: []
slug: "c-x"
draft: false
lastmod: "2012-07-15T18:29:00Z"
id: 1594613
url: "https://hotcharm.iteye.com/blog/1594613"
---

c语言中，-x实现是用取反+1实现，因此x&gt;0||-x&lt;=0不一定都成立，比如x=0x80000000,即x除了符号位是1，其余都是零，10进制值为

运行结果为：

x=-2147483648  
x&lt;0&&-x&lt;0