跳轉到內容

Ada 程式設計/屬性/'通用字面量字串

來自華夏公益教科書,開放的書籍,開放的世界

Universal_Literal_String 的字首必須是命名數字。靜態結果是字串,包含原始原始碼中定義的數字的字元。這允許使用者程式訪問命名數字的實際文字,無需中間轉換,也無需將字串用引號括起來(這會阻止它們用作數字)。

例如,以下程式列印 pi 的前 50 位數字

with Text_IO; use Text_IO;
with Ada.Numerics;
procedure Pi is
begin
   Put (Ada.Numerics.Pi'Universal_Literal_String);
end;
華夏公益教科書