Inconsistent Syntax Rules - Numbers

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default Inconsistent Syntax Rules - Numbers

    First piece of business: We are running CF 7.0.1 with hotfix hf70161212
    applied. Now for the problem.
    There is a piece of code in one of our programs that looks like this:
    <cfif RDS_TOTAL GT 98.9 >
    <cfset RDS_TOTAL_CALC = 4>
    <cfelseif RDS_TOTAL GTE 97.5 AND RDS_TOTAL LTE 98.9>
    <cfset RDS_TOTAL_CALC = 3>
    <cfelseif RDS_TOTAL GTE 90 AND RDS_TOTAL LTE 97.4>
    <cfset RDS_TOTAL_CALC = 2>
    <cfelseif RDS_TOTAL GTE 85 AND RDS_TOTAL LTE 89.9>
    and so on....

    We had a rds_total value of 97.5 that was recognized by the above code and
    rds_total_calc was set to 3. When the rds_total was 97.4 the rds_total_calc
    was not set and the program failed.

    The resolution to the problem was to re-code the one line of
    <cfelseif RDS_TOTAL GTE 90 AND RDS_TOTAL LTE 97.4>
    to:
    <cfelseif #numberformat(RDS_TOTAL, "999.9")# GTE 90.0 AND
    #numberformat(RDS_TOTAL, "999.9")# LTE 97.4>

    With that modification the program recognized 97.4, rds_total_calc was set to
    2, and the program updated the record successfully.

    Please help me understand why this one line had to be re-coded. Is there a
    bug in CF 7? Thanks.

    Les118 Guest

  2. Similar Questions and Discussions

    1. 3D export 'rules'
      Where would I find a complete set of 'rules' or guildelines for exporting from 3D Max to sw3d? I know tehre are a few technotes at Adobe like:...
    2. NAT rules in ppp
      This is the rule i presently have in my ppp.conf file nat port tcp 10.100.6.10:6881-6999 6881-6999 What im wanting to change without the need...
    3. MWM logo rules
      Hello, even if this topic has been discussed before in this group, I'm still confused. I'm about to finish a commercial Director project. As far...
    4. paragraph rules
      i'm using freehand 9 - is it possible to set paragraph rules , and er how? like this: (obviously i could draw my own lines between each text line...
    5. Message Rules
      I have Windows XP Pro and am using Microsoft Outlook Express for my e-mail. I set my "Message Rules" to delete any mail which contains certain...
  3. #2

    Default Re: Inconsistent Syntax Rules - Numbers

    I don't know the answer, but, I would test this line for sure:
    <cfelseif RDS_TOTAL GTE 85 AND RDS_TOTAL LTE 89.9>

    You might have the same problem.

    also, adding .0 to the first number would probably be just as effective as
    what you did, and less work.


    Dan Bracuk Guest

  4. #3

    Default Re: Inconsistent Syntax Rules - Numbers

    Thanks for the response. Yes, we had the same idea and added the .0 to the first number and it still failed.
    Les118 Guest

  5. #4

    Default Re: Inconsistent Syntax Rules - Numbers

    It also worked fine for me with MX7



    <cfset RDS_TOTAL = "97.4">

    <cfif RDS_TOTAL GT 98.9 >
    <cfset RDS_TOTAL_CALC = 4>
    <cfelseif RDS_TOTAL GTE 97.5 AND RDS_TOTAL LTE 98.9>
    <cfset RDS_TOTAL_CALC = 3>
    <cfelseif RDS_TOTAL GTE 90 AND RDS_TOTAL LTE 97.4>
    <cfset RDS_TOTAL_CALC = 2>
    <cfelseif RDS_TOTAL GTE 85 AND RDS_TOTAL LTE 89.9>
    <cfset RDS_TOTAL_CALC = 1>
    <cfelse>
    <cfset RDS_TOTAL_CALC = 1>
    </cfif>

    <cfoutput>
    RDS_TOTAL = #RDS_TOTAL#<br>
    RDS_TOTAL_CALC = #RDS_TOTAL_CALC#<br>
    </cfoutput>

    mxstu Guest

  6. #5

    Default Re: Inconsistent Syntax Rules - Numbers

    Is RDS_TOTAL_CALC the result of a calculation in CF or is it straight out of a
    database with precision set to exactly one decimal? The latter should work
    forever. The former or a DB definition that results in float could often fail.
    Calculation results (esp now with a Java backbone) may often be rendered
    internaly as float and actually carry extra decimals. With CF's loose type
    casting you never know for sure whether you're comparing apples to apples or
    oranges. That's why the explicit Numberformat solved your problem, you wound
    up with apples and apples. Actually the structure never really covered all the
    bases. It left out values between 97.5 and 97.4 (whether or not they were
    expected, they still wern't covered).
    On general principles you should have been coded: RDS_TOTAL GTE 90 AND
    RDS_TOTAL LT 97.5, ie less than the prio boundary not less than or equal to a
    different boundary. As to why it worked before, what CF version were you? I'd
    suspect that version used the literal operands to construct a temporary
    NumberFormat on your behalf, esp if your version was pre-Java (5.0 I believe,
    I'm stuck on 4.5 seemingly forever now)

    JMGibson3 Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139