PC is IEEE754?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew G. Koptyaev

    PC is IEEE754?

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

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

    It's true ?



  • Jerry Stuckle

    #2
    Re: PC is IEEE754?

    Andrew G. Koptyaev wrote:
    As I understand PC with x86 CPU is IEEE754 floating point standart.
    >
    Then out of:
    <?php
    print (19.6*100)!==(d ouble)1960;
    ?>
    will be 1.
    >
    It's true ?
    >
    Did you try it?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Tim Roberts

      #3
      Re: PC is IEEE754?

      "Andrew G. Koptyaev" <koptyaev@gmail .comwrote:
      >
      >As I understand PC with x86 CPU is IEEE754 floating point standart.
      >
      >Then out of:
      ><?php
      >print (19.6*100)!==(d ouble)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, timr@probo.com
      Providenza & Boekelheide, Inc.

      Comment

      • rf

        #4
        Re: PC is IEEE754?


        "Andrew G. Koptyaev" <koptyaev@gmail .comwrote in message
        news:gdd0ev$rju $1@aioe.org...
        As I understand PC with x86 CPU is IEEE754 floating point standart.
        >
        Then out of:
        <?php
        print (19.6*100)!==(d ouble)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.


        Comment

        Working...