Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
File size: 786 Bytes
4365a98 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
(*
Author: René Thiemann
Akihisa Yamada
License: BSD
*)
section \<open>Show for Real (Algebraic) Numbers -- Approximate Representation\<close>
text \<open>We implement the show-function for real (algebraic) numbers by calculating the
number precisely for three digits after the comma.\<close>
theory Show_Real_Approx
imports
Show_Real_Alg
Show.Show_Instances
begin
overloading show_real_alg \<equiv> show_real_alg
begin
definition show_real_alg[code]: "show_real_alg x \<equiv> let
x1000' = floor (1000 * x);
(x1000,s) = (if x1000' < 0 then (-x1000', ''-'') else (x1000', ''''));
(bef,aft) = divmod_int x1000 1000;
a' = show aft;
a = replicate (3-length a') (CHR ''0'') @ a'
in
'' ~'' @ s @ show bef @ ''.'' @ a"
end
end
|