-
This code generates two decimals that are to be subtracted. The goal is to give practice subtracting a wide range of decimals. Sometimes the end product (/:ans) has a strange value, such as -78.1210000000001, when subtracting simple numbers such as 790.72 from 868.841.
-----------------------------------------------------------------------------------------------------------------
****************CODE******************************
Set Variable: "/:part1" = ""
Set Variable: "/:part2" = ""
Set Variable: "/:count" = "1"
Comment: subtraction
Loop While (/:count < 3)
Set Variable: "/:r" = Random (3)+1
If (/:r = 1)
Set Variable: "/:firsthalf" = Random(9)+1
Else If (/:r = 2)
Set Variable: "/:firsthalf" = Random (90)+10
Else If (/:r = 3)
Set Variable: "/:firsthalf" = Random (900)+100
End If
Set Variable: "/:r2" = Random (3)+1
If (/:r2 = 1)
Set Variable: "/:secondhalf" = Random (9)+1
Set Variable: "/:secondhalf" = /:secondhalf *.1
Else If (/:r2 = 2)
Set Variable: "/:secondhalf" = Random (90)+10
Set Variable: "/:secondhalf" = /:secondhalf *.01
Else If (/:r2 = 3)
Set Variable: "/:secondhalf" = Random (900)+100
Set Variable: "/:secondhalf" = /:secondhalf *.001
End If
Set Variable: "/:part"&/:count = /:firsthalf + /:secondhalf
Set Variable: "/:count" = /:count + 1
End Loop
Set Variable: "/:ans" = /:part1 - /:part2
-----------------------------------------------------------------------------------------------------------------
*****************List of variables from test movie**********************
Layer #0:
Variable _level0:power = "0"
Variable _level0:h = "2"
Variable _level0:input = ""
Variable _level0:hint = ""
Variable _level0:part1 = "790.72"
Variable _level0:part2 = "868.841"
Variable _level0:count = "3"
Variable _level0:r = "3"
Variable _level0:firsthalf = "868"
Variable _level0:r2 = "3"
Variable _level0:secondhalf = "0.841"
Variable _level0:ans = "-78.1210000000001"
Any help on this is greatly appreciated.
TIA
asnyder@lessonlink.com
-
livingfire,
Can't give a lot of help, but this has explained a problem
I have had. After seeing your write up I checked it out.
This is all you need in order to see the problem. Probably
other ways to see it also. I just verified that there was a problem.
Sure hope someone corrects me and shows me my mistake!!
Set Variable: "part1" = 7.1
Set Variable: "part2" = 8.1
Set Variable: "/:ans" = /:part1 - /:part2
Variable _level0:ans = -0.999999999999999
or
Set Variable: "part1" = 8.2
Set Variable: "part2" = 8.1
Set Variable: "/:ans" = /:part1 - /:part2
Variable _level0:ans = 0.100000000000001
This looks like a real bug and it is constant with certain
sequences of numbers. It also fails in Flash4 with the ver4 plugin.
Makes me wonder if this isn't wrong and I am missing something
very simple. But I don't think so!!!!
I know this didn't help much.
:)MA
[Edited by Magister Arenei on 10-26-2000 at 12:34 AM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|