Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,458
    Thanks
    76
    Thanked 4,373 Times in 4,338 Posts
    Also, just because the *DISPLAY* of a NUMBER may look the same as a string, it may not be exactly equal!

    This is a contrived example, just because I don't happen to have a real one sitting around. But I guarantee you that SOMEDAY you will hit a real one like this:
    Code:
    <script>
    var m = 0.001;
    var n = 0;
    for ( var s = 1; s <= 300; ++s ) { n += m; }
    document.write( 0.001 * 300 + " should be the same as 0.3, is it? " + ( n == 0.3 ) );
    </script>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  2. #17
    New Coder
    Join Date
    Jun 2012
    Posts
    80
    Thanks
    0
    Thanked 18 Times in 18 Posts
    I agree with Old Pedant, it's really risk to carry "cbiindex = cbi_index.toFixed(1)" without "cbi_index" tab on at "cbiinfo = new Array(cbiindex, cbitxt, cbi_image)", why don't put "cbi_index" insert "cbiindex" or at least use "toString()" insert "toFixed(1)" unless "cbiindex" only use for show a message, not for caculate but better use "toFixed(2)" for safety.

    PHP Code:
    function chandler(inTempinHum) {

        var 
    temp cTempToC(inTemp);
        var 
    hum inHum;

        
    cbi_index = (((110 1.373 hum) - 0.54 * (10.20 temp)) * (124 Math.pow(10, -0.0142 hum))) / 60;
        
    cbiindex cbi_index.toString();
        
    cbi_index Number(cbiindex);


        var 
    Img = ["31""25""16"];
        var 
    Lv = [907550];
        var 
    Match 0;

        
    cbiimg "/Fire";

        for (
    index in Lv)
        if (
    cbi_index >= Lv[index]) { cbitxt langChandler[index 3]; cbiimg += Img[index]; } 
        else { if (
    cbi.index 97.5) { cbitxt langChandler[4];  cbiimg += "32"; }
               else { 
    cbitxt langChandler[0]; cbiimg += "0"; }
        }

        
    cbitxt langChandlerMsg ': ' cbitxt;
        
    cbi_image '<img src="' imagedir2 cbiimg '.gif" alt="' cbitxt '" title="' cbitxt '" />';
        
    cbiinfo = new Array(cbiindexcbitxtcbi_image);
        return 
    cbiinfo;

    Last edited by Richter; 09-01-2013 at 04:46 PM. Reason: Typo


 
Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •