Re: div bug
Re: div bug
- Subject: Re: div bug
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 4 Aug 2009 07:54:51 -0400
If you're looking for "do shell script" calculators, you may wish to
check out bc (or if you're comfortable with RPN, dc), both of which do
arbitrary-precision arithmetic on strings of digits, rather than
working with floats.
On 8/4/09, Michael Ghilissen <email@hidden> wrote:
> Hi Philip,
>
> I am discovering the value of tclsh, after reading your post and I
> would like to explore from there.
>
> Does that mean that tclsh could be used as a calculator to overcome
> the math shortcomings in AS? I found these tutorials:
>
> http://www.beedub.com/book/3rd/Tclintro.pdf
> http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html
>
> For example, it is quite easy to write this tclsh script in AS:
> puts "Start"
> set i 0
> while {$i < 10} {
> puts "I inside third loop: $i"
> incr i
> puts "I after incr: $i"
> }
> do shell script "tclsh <<< 'puts \"Start\"; set i 0; while {$i < 10}
> {puts \"I inside third loop: $i\"; incr i; puts \"I after incr: $i\"}'"
>
> Now, a test that I did with arrays:
>
> do shell script "tclsh <<< 'array set array1 [list {123} {Rene
> Descartes} \\
> {234} {Richard Lionheart} \\
> {345} {Leonardo da Vinci} \\
> {456} {Julius Caesar} ];
> puts \"Array1 has [array size array1] entries\\n\"
> puts \"Array1 has the following entries: \\n [array names array1] \\n\"
> puts \"ID Number 123 belongs to $array1(123)\\n\"
> ' "
>
>
> Do you think it's overkill; or is there a benefit in pursuing this
> approach to integrate complex calculations/computaions in AS?
>
>
> Michael Ghilissen
>
>
>
>
>
> On Aug 4, 2009, at 3:36 AM, Philip Aker wrote:
>
>> On 2009-08-04, at 00:12:54, julifos wrote:
>>
>>> Just as someone found out it was OK mixing soda with chocolate, Mr.
>>> Bansemer found this funny bug. Please, check it out and report!
>>
>>> set n to 1.015 * 100 --> 101.5
>>> set n to n + 0.5 --> 102.0
>>> n div 1 --> 101 --> (!)
>>
>> Doesn't "float" on my setup either (10.5.7/Intel).
>>
>> do shell script "tclsh <<< 'puts [expr ((1.015 * 100) + 0.5) / 1]'"
>>
>> Philip Aker
>> echo email@hidden@nl | tr a-z@. p-za-o.@
>>
>> Democracy: Two wolves and a sheep voting on lunch.
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list (applescript-
>> email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>
>
--
Sent from my mobile device
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
References: | |
| >div bug (From: julifos <email@hidden>) |
| >Re: div bug (From: Philip Aker <email@hidden>) |
| >Re: div bug (From: Michael Ghilissen <email@hidden>) |