Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compare of reals. #782

Merged
merged 1 commit into from
Nov 12, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dmd2/root/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ longdouble Port::strtold(const char *buffer, char **endp)
#include <wchar.h>
#include <stdlib.h>
#include <limits> // for std::numeric_limits
#include "target.h"

double Port::nan;
longdouble Port::ldbl_nan;
Expand Down Expand Up @@ -250,7 +251,7 @@ int Port::fequal(longdouble x, longdouble y)
/* In some cases, the REALPAD bytes get garbage in them,
* so be sure and ignore them.
*/
return memcmp(&x, &y, 10) == 0;
return memcmp(&x, &y, Target::realsize - Target::realpad) == 0;
}

char *Port::strupr(char *s)
Expand Down Expand Up @@ -492,6 +493,7 @@ longdouble Port::strtold(const char *p, char **endp)
#include <wchar.h>
#include <float.h>
#include <assert.h>
#include "target.h"

double Port::nan;
longdouble Port::ldbl_nan;
Expand Down Expand Up @@ -689,7 +691,7 @@ int Port::fequal(longdouble x, longdouble y)
/* In some cases, the REALPAD bytes get garbage in them,
* so be sure and ignore them.
*/
return memcmp(&x, &y, 10) == 0;
return memcmp(&x, &y, Target::realsize - Target::realpad) == 0;
}

char *Port::strupr(char *s)
Expand Down