[tw] Re: [twc] display and (re)calculate simple operations
On Tuesday, February 4, 2014 4:24:36 AM UTC-8, julien23 wrote: > > are Math.floor Math.pow ... depending of a plugin I might not have ? > "Math" is a standard javascript object that defines a whole bunch of mathematical functions http://www.w3schools.com/jsref/jsref_obj_math.asp Le mardi 4 février 2014 13:23:10 UTC+1, julien23 a écrit : >> >> Thank you Eric >> >> I still have "108.95-84.72 = 24.234" >> I'll figure out why later >> > The extra digits are apparently a result of innaccuracy in the least significant bit of javascript's floating point calculations. The expression using Math.floor() and Math.pow() basically multiplies the number by a power a ten (to shift the decimal to the right), then truncates the value (discarding any remaining decimal digits), and then divides by the same power of ten to shift the decimal point back to the left. The 2nd argument in Math.pow(10,16) is the number of decimal digits to retain. When I tried this on my system (Win7/Chrome), keeping 16 decimal digits seemed to work (eliminating the last, spurious digit.. and the zeros leading up to it). Try changing the 2nd argument to a lower number, until the extra digits disappear. enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios YOUR DONATIONS ARE VERY IMPORTANT! HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... http://TiddlyTools.github.com/fundraising.html#MakeADonation Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.
[tw] Re: [twc] display and (re)calculate simple operations
are Math.floor Math.pow ... depending of a plugin I might not have ? Le mardi 4 février 2014 13:23:10 UTC+1, julien23 a écrit : > > Thank you Eric > > I still have "108.95-84.72 = 24.234" > I'll figure out why later > > Regards > > Julien > > Le mardi 4 février 2014 12:06:42 UTC+1, Eric Shulman a écrit : >> >> On Tuesday, February 4, 2014 1:18:02 AM UTC-8, julien23 wrote: >>> >>> I made this tiddler: >>> [[calcTid]] >>> $1 >>> And I call it with: >>> [[test]] >>> <> >>> it works almost fine : 24.234 >>> >>> I wish I could >>> >>>- remove the extra 4 >>>- write litteraly 108.95-84.72=24.23 without writing twice the >>>operation like >>><> >>> >>> Try this: >> >> Change [[calcTid]] to: >> /% >> !out >> $1=$2 >> !end >> %/<> Math.pow(10,16) }}>> >> then, to call it in [[test]], write: >> <> >> >> >> enjoy, >> -e >> Eric Shulman >> TiddlyTools / ELS Design Studios >> >> YOUR DONATIONS ARE IMPORTANT! >> HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... >>http://TiddlyTools.github.com/fundraising.html#MakeADonation >> >> Professional TiddlyWiki Consulting Services... >> Analysis, Design, and Custom Solutions: >>http://www.TiddlyTools.com/#Contact >> > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.
[tw] Re: [twc] display and (re)calculate simple operations
Thank you Eric I still have "108.95-84.72 = 24.234" I'll figure out why later Regards Julien Le mardi 4 février 2014 12:06:42 UTC+1, Eric Shulman a écrit : > > On Tuesday, February 4, 2014 1:18:02 AM UTC-8, julien23 wrote: >> >> I made this tiddler: >> [[calcTid]] >> $1 >> And I call it with: >> [[test]] >> <> >> it works almost fine : 24.234 >> >> I wish I could >> >>- remove the extra 4 >>- write litteraly 108.95-84.72=24.23 without writing twice the >>operation like >><> >> >> Try this: > > Change [[calcTid]] to: > /% > !out > $1=$2 > !end > %/< Math.pow(10,16) }}>> > then, to call it in [[test]], write: > <> > > > enjoy, > -e > Eric Shulman > TiddlyTools / ELS Design Studios > > YOUR DONATIONS ARE IMPORTANT! > HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... >http://TiddlyTools.github.com/fundraising.html#MakeADonation > > Professional TiddlyWiki Consulting Services... > Analysis, Design, and Custom Solutions: >http://www.TiddlyTools.com/#Contact > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.
[tw] Re: [twc] display and (re)calculate simple operations
On Tuesday, February 4, 2014 1:18:02 AM UTC-8, julien23 wrote: > > I made this tiddler: > [[calcTid]] > $1 > And I call it with: > [[test]] > <> > it works almost fine : 24.234 > > I wish I could > >- remove the extra 4 >- write litteraly 108.95-84.72=24.23 without writing twice the >operation like ><> > > Try this: Change [[calcTid]] to: /% !out $1=$2 !end %/<> then, to call it in [[test]], write: <> enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios YOUR DONATIONS ARE IMPORTANT! HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... http://TiddlyTools.github.com/fundraising.html#MakeADonation Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.
[tw] Re: [twc] display and (re)calculate simple operations
Thank you Eric I slightly tuned your code I made this tiddler: [[calcTid]] $1 And I call it with: [[test]] <> it works almost fine : 24.234 I wish I could - remove the extra 4 - write litteraly 108.95-84.72=24.23 without writing twice the operation like <> Regards Julien Le lundi 3 février 2014 15:15:26 UTC+1, julien23 a écrit : > > Hi all > > Is there a way to display and (re)calculate simple operations like 108.95 > - 84.72 = 24.23 without the need of an external calculator ? > > Regards > > Julien > > > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.
[tw] Re: [twc] display and (re)calculate simple operations
On Monday, February 3, 2014 6:15:26 AM UTC-8, julien23 wrote: > > Hi all > Is there a way to display and (re)calculate simple operations like 108.95 > - 84.72 = 24.23 without the need of an external calculator ? > There's no *built-in* calculation engine for TWC... However, you *can* embed Javascript code to compute and generate output. Here's two methods: 1) http://www.TiddlyTools.com/#InlineJavascriptPlugin after installing this plugin, you can embed something like: var val=108.95-84.72; return val.toString(); 2) using "evaluated parameters" and <> transclusion of a "hidden section" /% !out $1 !end %/<> enjoy, -e Eric Shulman TiddlyTools / ELS Design Studios EVERY DONATION IS IMPORTANT! HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"... http://TiddlyTools.github.com/fundraising.html#MakeADonation Professional TiddlyWiki Consulting Services... Analysis, Design, and Custom Solutions: http://www.TiddlyTools.com/#Contact -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/groups/opt_out.