Translated message

A translation of this page exists in English.

プログラムが `-0.0` の数値を算出します。これは正しい結果ですか?

Solution Verified - Updated -

Issue

  • このプログラムが -0.0 の数値を算出します。これは正しい結果ですか? それとも不具合ですか?
$ cat float.c
#include<stdio.h>

int main(){  
  double a = 0;  
  double b = a * (-1.0);  
  printf("%f", b);  
  return 0;  
}

$ gcc float.c

$ ./a.out
-0.00000

Environment

  • Red Hat Enterprise Linux 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content