• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
number with one decimal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

number with one decimal


  • Subject: number with one decimal
  • From: Willem <email@hidden>
  • Date: Mon, 18 Jul 2011 21:26:51 +0200

I am stuck with rounding an number to one decimal, something strange is happening. I have this applescript in Xcode 3.1.4:

line 1: set aantalvragen to contents of text field "aantalvragenveld" as integer -- aantalvragenveld is a field where i can put in the number of questions on a test (voor my students)
line 2: set aantalgoed to contents of text field "aantalgoedveld" as integer --aantalgoedveld is a field where i can put the number of correct questions
line 3: set resultaat to (aantalgoed * 90 / aantalvragen) + 10 as integer --now the result is between 10 and 100, but it schould be between 1 and 10 (in Holland we like this ;)
line 4: set contents of text field "Resultaatveld" to resultaat / 10 --and now its between 1 and 10 with one decimal.

But, the strange thing is when aantalvragen is 10 and aantalgoed is 8 , then in line 3 resultaat is 82 (thats oke), but in line 4 its 8,19999999999999 (this should be 8,2)

So applescript thinks that 82 / 10 = 8,1999999999

It does not work to round things.

As i said, i am stuck

hope you can help
 _______________________________________________
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

  • Follow-Ups:
    • Re: number with one decimal
      • From: Deivy Petrescu <email@hidden>
    • Re: number with one decimal
      • From: Bill Briggs <email@hidden>
    • Re: number with one decimal
      • From: Steve Thompson <email@hidden>
    • Re: number with one decimal
      • From: Doug McNutt <email@hidden>
    • Re: number with one decimal
      • From: Stan Cleveland <email@hidden>
    • Re: number with one decimal
      • From: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Indesign data merge
  • Next by Date: Re: number with one decimal
  • Previous by thread: Re: ScriptEditorFormatting
  • Next by thread: Re: number with one decimal
  • Index(es):
    • Date
    • Thread