473,320 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PC is IEEE754?

As I understand PC with x86 CPU is IEEE754 floating point standart.

Then out of:
<?php
print (19.6*100)!==(double)1960;
?>
will be 1.

It's true ?

Oct 18 '08 #1
3 2660
Andrew G. Koptyaev wrote:
As I understand PC with x86 CPU is IEEE754 floating point standart.

Then out of:
<?php
print (19.6*100)!==(double)1960;
?>
will be 1.

It's true ?
Did you try it?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Oct 18 '08 #2
"Andrew G. Koptyaev" <ko******@gmail.comwrote:
>
As I understand PC with x86 CPU is IEEE754 floating point standart.

Then out of:
<?php
print (19.6*100)!==(double)1960;
?>
will be 1.

It's true ?
As Jerry said, you can find out for yourself whether this prints 1 or not.

However, I would like to point out that IEEE-754 compliance does NOT
guarantee the result. 19.6 cannot be represented exactly in binary. In
binary, it is an infinitely repeating value. Thus, the floating point
representation will be an approximation -- very close to 19.6, but not
exactly equal.

When you multiply by 100, it is quite difficult (without knowing the exact
binary representation) to predict whether rounding will help or hurt.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 19 '08 #3
rf

"Andrew G. Koptyaev" <ko******@gmail.comwrote in message
news:gd**********@aioe.org...
As I understand PC with x86 CPU is IEEE754 floating point standart.

Then out of:
<?php
print (19.6*100)!==(double)1960;
Begs the question: Why multiply by 100? Is 19.6 perhaps a $.cents amount? If
so then don't. Store and perform calculations on monetory amounts in
cents(which are always integers and integers are stored exactly in floating
point) and only convert (with suitable rounding) to $s on output.
Oct 19 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: David O'Farrell | last post by:
Is this only on solaris ? Python 2.3.3 (#1, Mar 19 2004, 16:18:33) on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> a= >>> print a.count(333),...
53
by: Zhiqiang Ye | last post by:
Hi, All I am reading FAQ of this group. I have a question about this: http://www.eskimo.com/~scs/C-faq/q7.31.html It says: " p = malloc(m * n); memset(p, 0, m * n); The zero fill is...
118
by: ramasubramanian.rahul | last post by:
hi .. can we design a program in c which will point out the possible memory leaks in any given c file and fix them.... i am trying to come with something like this but do not know where to start......
1
by: gnanapoongothai | last post by:
Hi, Any idea about how to convert floating point to IEEE format. thanxs,
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
39
by: rembremading | last post by:
Hi all! The following piece of code has (for me) completely unexpected behaviour. (I compile it with gcc-Version 4.0.3) Something goes wrong with the integer to float conversion. Maybe somebody...
1
by: Ravishankar S | last post by:
Hello C-Experts, Is there any predefined constant in Std C which specifed that the implementation uses the IEEE754 standard for floating point operation ? Regards, Ravishankar
6
by: Pavel | last post by:
Hello, Does anyone know a (preferably open-source) multi-platform C or C++ library that would be able to write and read C/C++ doubles and floats to/from streambuf, char array or similar device...
2
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.