ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 27 Oct 2013 20:21:00 +0100Artin decomposition for p-adic numbershttps://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/How can I decompose a p-adic number
... d_2 d_1 d_0. d_{-1} ... d_{-k}
into its integer part
d_2 d_1 d_0.
and fractional part
. d_{-1} ... d_{-k} ?
The does not seem to exist a kind of floor function.
Sun, 27 Oct 2013 03:06:49 +0100https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/Answer by tmonteil for <p>How can I decompose a p-adic number</p>
<p>... d_2 d_1 d_0. d_{-1} ... d_{-k}</p>
<p>into its integer part</p>
<p>d_2 d_1 d_0.</p>
<p>and fractional part</p>
<p>. d_{-1} ... d_{-k} ?</p>
<p>The does not seem to exist a kind of floor function.</p>
https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/?answer=15617#post-id-15617You can use the `.slice()` method. For the `frac` function, you may have to decide wether you want to keep the precision of your adic number or if you want to reset it to 1:
sage: floor_adic = lambda a : a.slice(0, a.precision_absolute())
sage: frac_adic = lambda a : a - a.slice(0, a.precision_absolute())
sage: frac_adic_noprec = lambda a : a.slice(a.valuation(), 0)
sage: K = Qp(11); K
11-adic Field with capped relative precision 20
sage: b = K(3211/11^2); b
10*11^-2 + 5*11^-1 + 4 + 2*11 + O(11^18)
sage: floor_adic(b)
4 + 2*11 + O(11^18)
sage: frac_adic(b)
10*11^-2 + 5*11^-1 + O(11^18)
sage: frac_adic_noprec(b)
10*11^-2 + 5*11^-1 + O(11^0)
Sun, 27 Oct 2013 07:12:07 +0100https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/?answer=15617#post-id-15617Answer by Klaus Scheicher for <p>How can I decompose a p-adic number</p>
<p>... d_2 d_1 d_0. d_{-1} ... d_{-k}</p>
<p>into its integer part</p>
<p>d_2 d_1 d_0.</p>
<p>and fractional part</p>
<p>. d_{-1} ... d_{-k} ?</p>
<p>The does not seem to exist a kind of floor function.</p>
https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/?answer=15618#post-id-15618Thank you very much!Sun, 27 Oct 2013 07:25:15 +0100https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/?answer=15618#post-id-15618Comment by kcrisman for <p>Thank you very much!</p>
https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/?comment=16844#post-id-16844If this helped you, please click the accept button in the answer! Then others will know that this question has a correct answer when they search.Sun, 27 Oct 2013 20:21:00 +0100https://ask.sagemath.org/question/10663/artin-decomposition-for-p-adic-numbers/?comment=16844#post-id-16844