Karim Belabas on Mon, 02 Sep 2024 17:43:31 +0200
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: How to show few decimal digits of a real number?
|
- To: Georgi Guninski <gguninski@gmail.com>
- Subject: Re: How to show few decimal digits of a real number?
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Mon, 2 Sep 2024 17:43:06 +0200
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1725291788; c=relaxed/relaxed; bh=/Zi2WzjdjV8wxtKb21ubDgwQGcsV1v8vLOP38Scd3qY=; h=DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; b=v6/T2leyi01pSh7cI3aXnj7z0NHvgkMHh47IHXt6Fb4oXRqUWd74bFfy4F6TSY39g31/u8Xe0InlFdgOF7v8iHztaUrNDxK1rNorgrhL6gs/KetruPUFZmyCuB62mjS247/X5NkFj9QG/zgivXRUF0G24R5H4ugQaR2F8yq71quFD3opRnotzTBlEPiylAZC4OnxXm8heZ0uZ4TbBjOtk2rVVaWKqjlUUFQhxwuLIGH3qCQF5RIr2lM+d5952M1sd0UkmbN3Ie/INNYnVGUGo6ipIjIb9t/GWqW/CUpgWhBIOdZ58ImMjEcR9xdmtkaw90ESoLfJZH6XBfHdgoFdsX3rrYkx64nSOi1AOEn+THamPP6h1zEcV6aiI3yc3ZPovmZL9FegnF08H1JEgvUaojjWZ/p7W+j9/0c9KbMypaf8a2v52wgop8dDuWUt9pJFwQ664/HsZUn5PIZTzdGmD8shlNsgjVu1CBIXQhKpIJmH/S50R13fd2W4Veg5gfgGv1qCD5vrWz3Ua6EtIAt2A6656Riw71KtwQW082d2TuH9YygdQflSJxYPjaLftan4QRfz0+VS2Ldans9K7wqBAq6oMLHN3RSnYrvr5RseLRVxgzv1xPUlAXEPBxNqkXRe8tw+c3+yPBXR4rblolnirpSVNwm9G0LzTtHV8/4fLrE=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1725291788; cv=none; b=WDrpzECDxlmqVUer2k+mlOENrOle0brn52dwtXPs2KUyq/3jW1JFGSifbaNObcIbnYL8wy/VWHBn5jWrGbb30PchLFUWEPOJCH02yD/senw3Xjq4/Oa0p0XSLZeGY/Um1hVoq9s3BuhmfqFH4tXFpkBs9kX9ucrEPG5Kp9YIAMJnUzsnN6TLwY/xDHlmpqu74Fd6PXEDMu25BuueGCjQXZiNjQehSB/EWl4+IE/WAXC/mcjdEUKV0oOd07DftbRFtU/J6rTlCMQJplFXgmNIQZWnhdHQsjCXB+1ucWv9K43ELSAvRm2cwq4yC8FTHM3uH6o3WLAkLNusFDXRSPTGjcchwVJYR1HYpS8qq3y0Z/4yXY9MeznRtQMq/kka095zg3A8ZAcTX773Or1D18EGVoIs6PEOfR8L5bAWjf4mlZuu0ITgvW4q7S00+jQ/BhMosQ63WSB07yHVIlX2Gez8azNNQg7srReNyd1+F8b1maEsctnpmWQ4NLCWzDKzAjpyqT5L2VEKGS2Bpk0FxiCg519Bh9oJAYE84bvvBAdNhrMOAWvbg2jRQJfJhQGa3CBDL/7Oq1DiHVOJabvqwi4JiAhSTdK2xwqkkTWQHIIE/GitmMcM/nrMedINwr9VFA9cmZDyIaiWupxtXsBaGV7FbBmQfOZYrOyJCmbKgJfd7vY=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Cc: pari-dev@pari.math.u-bordeaux.fr
- Delivery-date: Mon, 02 Sep 2024 17:43:31 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1725291788; bh=/Zi2WzjdjV8wxtKb21ubDgwQGcsV1v8vLOP38Scd3qY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HeO2bi4F8T4rsQBnSiG+fQeThhh20QYH7zMFyf5wnzeYvZz8Qz+ZG6HaW7QUFl7AS aBpFDSA1b/1gVgBUfm9lpQB9dF66tFcXYLtGmPstmLM9E4CIzUPI4yFoyWORnFqAI8 if7Jx0FoI/5jFO2+MxppKA5MOkH9L42oTBvHajnJFqSGYbEU5EH2oWPNueEhSGGSfK moNHbmvNrxeGEzYz6DqMULEBvt/tjntcO0WYUhH5Xk0Q703FmB5ZP1Sf7tUchsx1Xx JRujQ1x4gzmI88FAFjYsInEEBb+EkOKP5Ubpq/heN0Oczn516RcyUkyJeqvXQtRNSJ 3dfBs9heXIhKP/P+oangSeJLoYdlAg/tk6taeRvGvgVMVGteZSSKo2g7dmVA02yIX5 v9gJEBKY0phmALv82ppraWemzAEDbE6OWK2+ZaCNZT2g/Inz/24zyJ8K7yBSTeJK5A 6D35nse1gEuHYTk7EmCNfuTbT0sBgbglL56xlnDb5wMBhLBpLrtY4rWBuM4768eZBj st1pQOSx2dc/3WL/SyUGv50FrcrCIt656TcqubQo1Pxfg3g5zaqY27vMcpFaRWcGme uDal1CJZAFcvKNIs4kMBKm+aHB+vHId7A0l5ncInslNw8VULa8xOGm8MTdAMUYJhc6 bQSBrtgo1A3/fT3OZe+RomGg=
- In-reply-to: <CAGUWgD9o=qNk=4TYs=vOSTgqADSzyusKzhTQFCRGuP_JLQ++Tw@mail.gmail.com>
- Mail-followup-to: Georgi Guninski <gguninski@gmail.com>, pari-dev@pari.math.u-bordeaux.fr
- References: <CAGUWgD9o=qNk=4TYs=vOSTgqADSzyusKzhTQFCRGuP_JLQ++Tw@mail.gmail.com>
* Georgi Guninski [2024-09-02 17:40]:
> I have real number A and want to show only few fractional digits,
> how to do it directly without floor/round?
>
> The following doesn't work:
> ? precision(Pi)
> %3 = 38
> ? precision(Pi,2)
> %4 = 3.141592653589793239
See ??printf
? printf("%.2f", Pi)
3.14
Cheers,
K.B.
--
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/