|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
can I round infinity
I have an equation that will very often yield an infinite number so I need an interim step to cut the number off at around four decimal places. Does any one know a way to achieve this?
It would seem there should be a way to do this otherwise Flash’s usefulness with math would be seriously crippled but I haven’t been able to find anything in any of the resources I have. |
|
#2
|
|||
|
|||
|
no, infinity in flash is a defined value just being defined somehow as too big/small to compute anymore.
check out the reference on isFinite and the mentioned stuff there... |
|
#3
|
|||
|
|||
|
infinity
There has got to be a way to deal with this. PI is an infinite number but Flash works with it. I assume it is a predefined values cut off at a useable length but still, infinite numbers are going to be abundant unless you keep your math uses limited to 1 + 1 = 2.
|
|
#4
|
|||
|
|||
|
ah wait! stop! u r talking about the precision of floating point numbers?
well i never had a problem with it, as long as i wanted flash to measure out some pixel values or stuff or make it calculate fractals or stuff but for sure i would not trust it's correctness if i had the choice between my scientific calculator somewhere in the mees on my desktop and flash... but well it is able to nice algebra but if it suits a scientific topic i am not sure about that... |
|
#5
|
|||
|
|||
|
you may have found the solution already...but what you're talking about is an irrational number not an infinite number...pi is an irrational number which means it has no fractional equivalent, unless you live in indiana...rob
ok so after feeling bad about not even coming close to attempting to help you i had second thoughts...flash will store your variable in like a 32 bit or whatever memory location...so to say it has infinite decimal places would mean you had an infinite amount of memory in your machine...so why don't you just round all of them? i don't think the flash player will complain if you round .2 to the thousandth or anything...
__________________
Delenda est Carthago Last edited by rob5408 : April 28th, 2003 at 09:34 PM. |
|
#6
|
|||
|
|||
|
infinity
Rob, Gargoyle;
First of all I want to thank you guys for replying to my inquiry, I often find help on this site and sometimes all that is needed is a different perspective. In this case I think I have found the solution. I started by breaking the equation down into its various subcomponents and testing each one to find where the problem was coming in and also running a function that would round any value to a desired number of decimal places. What I discovered when I did this was that when I tried to string too much together in a single line of code it would return infinity but if I put each step on a separate line and stored that answer in a variable to be used in a subsequent line or step it would work. I don’t know if it’s just a miss-step in the way I am forming the code or what. But for instance something like var value1 = 6 / (Math.PI * Math.log (3)) ; would return infinity whereas value1 = Math.log (3); value2 = Math.PI * value1; solution = 6 / value2; would work just fine. I’m not sure what the problem is with the other approach. Maybe you guys know what’s up with this. BTW I also don’t know if my sample code I’ve put here will display correctly so my apologies if it displays a string of gobbldy gook. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > can I round infinity |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|