M
M
Michael Main2020-09-27 07:00:38
C++ / C#
Michael Main, 2020-09-27 07:00:38

Are there exact floating point data types in C/C++?

#include <stdio.h>


int main()
{
    float a = 1/3.0;
      if(a==0)
      {
      printf("NICE %lf",a);
    }
    else
    {
      printf("Not NICE %lf",a);
    }
    
    
  return 0;
}

#include <stdio.h>


int main()
{
    float a = 1/3;
      if(a==0)
      {
      printf("NICE %lf",a);
    }
    else
    {
      printf("Not NICE %lf",a);
    }
    
    
  return 0;
}

I know the reasons for this misunderstanding, so I don’t need to send articles explaining why this is happening. So, are there any data types in C / C ++ that more accurately represent floating point numbers, or do you just have to put up with it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question