Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Raylin on November 28, 2010, 03:56:48 pm

Title: fPart and 1+int(abs(log(X
Post by: Raylin on November 28, 2010, 03:56:48 pm
Is there any way to test this (1+int(abs(log()))) nested inside of an fPart?

For example, this:
Code: [Select]
1+int(abs(log(fPart(Xdoesn't work.

This gets the # of digits in a number.
Title: Re: fPart and 1+int(abs(log(X
Post by: calcdude84se on November 28, 2010, 03:58:30 pm
I'm confused... What do you mean by your first line?
Also, for a positive integer, 1+int(log(X works.
What is X?
Title: Re: fPart and 1+int(abs(log(X
Post by: nemo on November 28, 2010, 03:58:51 pm
so you want to get the number of digits in the fractional part of a number, am i right?
Title: Re: fPart and 1+int(abs(log(X
Post by: Raylin on November 28, 2010, 04:00:58 pm
so you want to get the number of digits in the fractional part of a number, am i right?

Yes.
Title: Re: fPart and 1+int(abs(log(X
Post by: calcdude84se on November 28, 2010, 04:03:41 pm
I don't think that's possible. You can tell how many leading 0's there are, but you can't tell how many significant figures there are.
log( won't distinguish much between .3333 and 1/3 x.x
Title: Re: fPart and 1+int(abs(log(X
Post by: nemo on November 28, 2010, 04:06:26 pm
i think you'd have to do the following, unless there's a neat math trick:

Code: [Select]
0->A
While fPart(X
10X->X
A+1->A
End

edit: and repeating decimals like 1/3 return 14 decimal places.
Title: Re: fPart and 1+int(abs(log(X
Post by: calcdude84se on November 28, 2010, 04:10:44 pm
Yeah, that's what I meant. No neat math trick, to my knowledge.
Your code should work fine, though. :)
Edit: I mean, we could use a nice recursive function...
Code: [Select]
f(x) = {0        x=int(x)}
       {1+f(x)  x<>int(x)}
Title: Re: fPart and 1+int(abs(log(X
Post by: FinaleTI on November 28, 2010, 04:12:25 pm
With Celtic III/DCS7, you could do:
Code: [Select]
length(det(1,X))-1-length(det(1,1+int(abs(log(X
;D
Title: Re: fPart and 1+int(abs(log(X
Post by: nemo on November 28, 2010, 04:13:30 pm
is that shorter than just using a loop though? it's probably faster granted
Title: Re: fPart and 1+int(abs(log(X
Post by: FinaleTI on November 28, 2010, 04:22:28 pm
That's probably larger than it needs to be.
How about:
Code: [Select]
length(det(1,X))-inString(det(1,X),".