Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38955 > unrolled thread
| Started by | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| First post | 2013-02-15 14:49 -0500 |
| Last post | 2013-02-15 14:49 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: python math problem Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-15 14:49 -0500
| From | Joel Goldstick <joel.goldstick@gmail.com> |
|---|---|
| Date | 2013-02-15 14:49 -0500 |
| Subject | Re: python math problem |
| Message-ID | <mailman.1842.1360957772.2939.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Feb 15, 2013 at 2:39 PM, Kene Meniru <Kene.Meniru@illom.org> wrote: > I am trying to calculate the coordinates at the end of a line. The length > and angle of the line are given and I am using the following formula: > > x = (math.sin(math.radians(angle)) * length) > y = (math.cos(math.radians(angle)) * length) > > The following are sample answers in the format (x, y) to the given > length/angle values of the line: > > 120/0 = (0.0, 25.0) > 120/89 = (24.9961923789, 0.436310160932) > 120/90 = (25.0, 1.53075794228e-15) > This is not a string, it is scientific notion for 1.53... times 10 to the -15th power. Because of rounding errors caused by doing floating point math on in binary, you get a very small number instead of 0. > 120/91 = (24.9961923789, -0.436310160932) > > Why am I getting a string number instead of the expected answer for 120/90 > which should be (25.0, 0.0). This happens at all multiples of 90 (i.e. 180 > and 270) > > -- > > Kene > :::::::::::::::::: > KeMeniru@gmail.com > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick http://joelgoldstick.com
Back to top | Article view | comp.lang.python
csiph-web