It just Does't add up!!!
This WebDNA talk-list message is from 1997
It keeps the original formatting.
numero = 15029
interpreted = N
texte = Hi... I cannot get this calculation to work!It works on paper but not with WebCatallog!All I want to do is:For every 2 items only charge 1 deliveryie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40I have to use [math] for the calculation and [format .1f] to do therounding up... as you can inly round up in the decimal places!Please take a look at the .tmpl file below and see it my math isincorrect or my coding is missing something!It is best viewed from web browser.WebStar 2.1 and WebCatalog Plugin 2.0ThanxMarko---------------------------------- Marko Bernyk---------------------------------- Senior System Engineer Technical Services Conexus Pty Ltd Sydney, Australia e-mail: marko@conexus.com.au http://www.conexus.com.au----------------------------------------markocalculations.tmpl---------For every 2 items only charge 1 delivery
ie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40
Simple... Work this out on paper
1 item
Half this = 0.5
Divide by 10 = 0.05
Round Up with [format .1f] = 0.1
Times by 10 = 1
2 items
Half this = 1
Divide by 10 = 0.1
Round Up with [format .1f] = 0.1
Times by 10 = 1
3 items
Half this = 1.5
Divide by 10 = 0.15
Round Up with [format .1f] = 0.2
Times by 10 = 2
4 items
Half this = 2
Divide by 10 = 0.2
Round Up with [format .1f] = 0.2
Times by 10 = 2
5 items
Half this = 2.5
Divide by 10 = 0.25
Round Up with [format .1f] = 0.3
Times by 10 = 3
Etc...
Here is how rounding works!
--------
Format Floating Point Numbers to 1 decimal place should round up at.x5
1.04=[format .1f] 1.04 [/format]
1.05=[format .1f] 1.05 [/format]
1.06=[format .1f] 1.06 [/format]
1.14=[format .1f] 1.14 [/format]
1.15=[format .1f] 1.15 [/format]
1.16=[format .1f] 1.16 [/format]
1.24=[format .1f] 1.24 [/format]
1.25=[format .1f] 1.25 [/format]
1.26=[format .1f] 1.26 [/format]
1.34=[format .1f] 1.34 [/format]
1.35=[format .1f] 1.35 [/format]
1.36=[format .1f] 1.36 [/format]
----Here are my calculations in a LOOP... they don't work!----
#items | /2 | /10 | Roundup | *10 | Total |
[loop start=1 &end=50 &advance=1][math]item[/math] | [math]roundup=temp/2[/math] | [math]roundup=roundup/10[/math] | [math]roundup=[format .1f][math]roundup[/math][/format][/math] | [math]total=roundup*10[/math] | $[math]total*10[/math] |
[/loop]
Associated Messages, from the most recent to the oldest:
Hi... I cannot get this calculation to work!It works on paper but not with WebCatallog!All I want to do is:For every 2 items only charge 1 deliveryie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40I have to use
[math] for the calculation and [format .1f] to do therounding up... as you can inly round up in the decimal places!Please take a look at the .tmpl file below and see it my math isincorrect or my coding is missing something!It is best viewed from web browser.WebStar 2.1 and WebCatalog Plugin 2.0ThanxMarko---------------------------------- Marko Bernyk---------------------------------- Senior System Engineer Technical Services Conexus Pty Ltd Sydney, Australia e-mail: marko@conexus.com.au http://www.conexus.com.au----------------------------------------markocalculations.tmpl---------For every 2 items only charge 1 delivery
ie: 1-2 items =$10, 2-3 items =$20, 4-5 items =$30, 6-7 items =$40
Simple... Work this out on paper
1 item
Half this = 0.5
Divide by 10 = 0.05
Round Up with [format .1f] = 0.1
Times by 10 = 1
2 items
Half this = 1
Divide by 10 = 0.1
Round Up with [format .1f] = 0.1
Times by 10 = 1
3 items
Half this = 1.5
Divide by 10 = 0.15
Round Up with [format .1f] = 0.2
Times by 10 = 2
4 items
Half this = 2
Divide by 10 = 0.2
Round Up with [format .1f] = 0.2
Times by 10 = 2
5 items
Half this = 2.5
Divide by 10 = 0.25
Round Up with [format .1f] = 0.3
Times by 10 = 3
Etc...
Here is how rounding works!
--------
Format Floating Point Numbers to 1 decimal place should round up at.x5
1.04=[format .1f] 1.04 [/format]
1.05=[format .1f] 1.05 [/format]
1.06=[format .1f] 1.06 [/format]
1.14=[format .1f] 1.14 [/format]
1.15=[format .1f] 1.15 [/format]
1.16=[format .1f] 1.16 [/format]
1.24=[format .1f] 1.24 [/format]
1.25=[format .1f] 1.25 [/format]
1.26=[format .1f] 1.26 [/format]
1.34=[format .1f] 1.34 [/format]
1.35=[format .1f] 1.35 [/format]
1.36=[format .1f] 1.36 [/format]
----Here are my calculations in a LOOP... they don't work!----
[math]temp=1[/math]>[math]item=1[/math]>[math]total=0[/math]>
#items | /2 | /10 | Roundup | *10 | Total |
[loop start=1 &end=50 &advance=1][math] roundup=0 [/math]>[math]item[/math] | [math]roundup=temp/2[/math] | [math]roundup=roundup/10[/math] | [math]roundup=[format .1f][math]roundup[/math][/format][/math] | [math]total=roundup*10[/math] | $[math]total*10[/math] |
[math]total=0[/math]>[math]item=item+1[/math]>[math]temp=item[/math]>[/loop]
Marko Bernyk
DOWNLOAD WEBDNA NOW!
Top Articles:
Talk List
The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...
Related Readings:
Make sure I understand this??? (1997)
IE problems persist (2004)
Intermitent problem using [referrer] (1997)
Search in 2 or more catalogs (1997)
Re:2nd WebCatalog2 Feature Request (1996)
Summing fields (1997)
Whats going on? (2000)
WebDNA Feature Request (2006)
MacAuthorize order data fields WAS:How To question... (1997)
Getting the domain of every request ... (2003)
WebCat/CyberStudio Compatibility (1998)
Secure server question (1997)
Logical and or in [hideif] (1997)
More on the email templates (1997)
can WC render sites out? (1997)
Secure Server (1997)
Summing fields (1997)
webcat2b12 CGI -- Date comparisons (1997)
PCS Frames (1997)
[Listdatabases] (2000)