- AVS Troubleshooting
- Number question
Archive: Number question
sidd
28th May 2003 06:51 UTC
Number question
Ok, i really dont wanna get flamed for this thread.. so if you feel like you are getting pissed off, please press the 'back' button now.
I need to return the digits within a number alone..
for example, from a random number number. 12345. i want to return the 3rd place from the right. (3). Or from the the number 54.123, it should return the number 1.
The code needs to work for number of any reasonable leangth
And needs to return a specifiable digit from the left or right (whichever you find more practical)
any suggestions would be great.
Magic.X
28th May 2003 07:02 UTC
*Cough* Thats really hard to do man. You know this could be done in any programming language but not in AVS itself because there's simply no way of determining the length of a stringconverted var.
Sorry, i don't have the slightest idea.
But if you'd tell waht you need it for there's maybe another solution.
Nic01
28th May 2003 07:03 UTC
You're lucky, I needed such thing when trying to do a point-frame relation (in my words, not yours) using only a few variables.
n1=n/pow(10,a)%10 where a is the place from right minus one.
Any faster solutions?
(attached is the preset I worked on using this system. definitely not done, don't steal!)
(progression is the old system, devised by skupers, 1.1 is the new version, still needs a lot of betterment)
sidd
28th May 2003 07:08 UTC
thats similar to what i had when i got stuck.
Ill check it for what i need when i get home.
Ill show you what it is when your done.. youll cream your pants.
[edit][b]I just downloaded winamp on this computer just to check out your idea.. Man, that is insane! i cant quite work out how it works, nor do i know how i can apply it to what i need..though.
From what i can see, this will only work for multiples of 10. Which is about as far as i got aswell.
Nic01
28th May 2003 07:18 UTC
n1=0.12345/pow(10,-5)%10
n1=0.12345/0.00001%10
n1=12345%10
n1=5
It works for nonintegerA.
Why would you need nonintegerB?
Oh, and AVS is limited to 2^32 (4294967296) and 2^-32, and for every step right of the decimal point, the limit left of dec point lowers.
What are you using this for?
sidd
28th May 2003 07:24 UTC
sorry, i keep editing my posts and deleting stuff. And then i come back and find that somone has just replied to the bit i deleted.
You just gave me an idea nic, im gonna go hame and try it out.
Magic.X
28th May 2003 07:43 UTC
Nic, i got that far too, but as i said first, how would you determine the length of a random floating point number to count it from the right (or the left) not starting at the middle piont?
You could only count down the decimals or up the real ones.
sidd
28th May 2003 08:22 UTC
yeah.. i guess that is the problem..
Here is the way i was doing it before
1> change float by multiplying be 10^number
2> kill remainder by subtracting number%1
3> subtract all the numbers to the left of the one you want, each multiplied by 10^(their respective position).
here is another, easier way to do it that i have just discovered courtesy of nic.
1> change float so that the first remainder is the number you want. get that remainder using %, assign to 'rm'.
2> then use rm as base to find the first decimal: rm-rm%(10^leangth of number-1)
as you can see, we are still quite stuck.
Jaheckelsafar
28th May 2003 08:30 UTC
length=if(above(number/100,0),3,length);
length=if(above(number/1000,0),4,length);
length=if(above(number/10000,0),5,length);
ugly and slow and finite, but should work.
sidd
28th May 2003 08:38 UTC
i dont think use finite code.. but ill try something like that.
UnConeD
28th May 2003 09:03 UTC
Here's what I use for displaying numbers:
(val*pow(10,-digit)-.499999999999)%10
for 'digit', use:
number: 0 0 3 . 1 4 1 5...
digits: 2 1 0 -1-2-3-4
The .49.. is necessary because otherwise quantities ending in 0 will get rounded off incorrectly. E.g. try displaying "10", which would come out as "00" if you'd use 0.5.
UnConeD
28th May 2003 09:25 UTC
Like this.... (had it lying around)
sidd
28th May 2003 09:47 UTC
UCD
YOU SLUT!!!
you stole my idea.
oh well, mine is better. not far off now. :D
Magic.X
28th May 2003 10:19 UTC
Whatever you try, UCD has done it before or is telling you it aint possible. Somehow its just depressing :p
sidd
28th May 2003 10:58 UTC
Well, as i said, mine is far better and far more advanced. (bragitty brag brag brag)
Its finished now!!!
Thanks to all who posted on this thread!
Now go here and see the finished deal!
The Variable Tracker Thread
sidd
28th May 2003 14:08 UTC
i just realised how amazing that progressions thing of yours is nic!
how would one go about increasing the number of points to hold/remember the previouse state for.
(eg, at the moment it only last for eight frames, because there is only 8 points. But if you add more points, it stops working)
Nic01
28th May 2003 16:32 UTC
I know that.
I can add more storage vars to increase either the length or the detail tenfold (hopefully), and even then it still won't use more vars than skupers' way.
sidd
29th May 2003 00:28 UTC
poohbar, otherwise it could be very useful for things like tentacles and stuff..
Here is what i would use that code for if you could make it better, and if you would let me steal it :D :D
these dont react to beat or specdata at all, because their path needs to remain completely predicatble at all times, so they look kindof dull. Nice effect though.
They work upon a static path, the further along i each point is, the lesser the point on that path is used. Each scope is slightly randomised so that they look like tails. And the path is completely different for different tadpoles.
I havnt used these in a preset yet because i dont know how to make them reactive. :( any ideas?
Nic01
29th May 2003 06:48 UTC
Holy, that's goddamned nice.
Steal no, borrow yes, give credit must.
I'll see what I can do with it.
sidd
29th May 2003 07:18 UTC
at the moment i cant use your code anyway.. i need the variables to hold for around 70-80 points (the maximum leanth of any of my scopes).
btw, unconed's 'anemone' preset from Whacko V sets off in a similar direction, although hes used multiple scopes for each tentacle (cheater).
UnConeD
29th May 2003 20:19 UTC
Method for storing variable data using Taylor-series approximation (only works well for data that is continuous up to the n'th derivative, n=4 in this case):
http://forums.winamp.com/showthread....ight=tentacles
sidd
30th May 2003 03:56 UTC
thank you :), give you full credit if i use yes?