My program results -0.0 value. Is this correct ?

Solution Verified - Updated -

Issue

  • This program results -0.0 value. Is this correct? A bug?
$ 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