On Wed, Apr 19, 2023 at 11:55:55AM -0700, Sid Andal wrote:
> Since, digits works with PAdicInteger only, one way is to try converting 
> from PAdicRational to PAdicInteger, then apply digits:
> 
> (3) -> PR ==> PAdicRational(11)
> (4) -> PI   ==> PAdicInteger(11)
> (5) -> 
> (5) -> x : PR := 1234
> 
>                                       2
>    (5)  2 + 2 11 + 10 11
> (6) -> 
> (6) -> y : PI := approximate(x, 3) :: PI
> 
>                                       2
>    (6)  2 + 2 11 + 10 11
> (7) -> 
> (7) -> digits(y)
> 
>    (7)  [2, 2, 10]
> (8) ->
> 
> Is there a more direct or more efficient way to convert a PAdicRational to 
> PAdicInteger?

If you _know_ that your p-adic rational in fact is an p-adic integer,
then official idiom is

retract(x)@PI

Unfortunately, ATM retract for p-adic rationals is unimplemented.  But
it would be easy to add it.

In general,

x - approximate(x, 0)::PR

is a p-adic integer, so you can split p-adic rational into integer
part and fractional part.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20230420002823.4oam4t6xp2xsrpor%40fricas.math.uni.wroc.pl.

Reply via email to