跳轉到內容

Ada 程式設計/關鍵字/delta

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

Ada. Time-tested, safe and secure.
Ada. 經久不衰,安全可靠。

這個關鍵字用於宣告 定點型別。Delta 代表 定點型別的絕對誤差界限;也就是說,delta 為編譯器提供一個提示,告訴它如何選擇該型別最小增量值,稱為該型別的Small。該 Small 值可以透過屬性 T'Small 訪問。

對於普通定點型別,它預設情況下為不大於 delta 的 2 的冪;它可以透過屬性子句指定為不大於 delta 的任何值。

對於十進位制定點型別,Small 值等於 delta,當然 delta 必須是 10 的冪。

type Fixed_Point is delta 0.01 digits 10;  -- A decimal fixed point type
My_Fixed_Point : Fixed_Point := 0.0;
...
My_Fixed_Point := 0.1;   -- Ok
My_Fixed_Point := 0.02;  -- Ok
My_Fixed_Point := 0.001; -- Oops - this value is too small.
                         -- It will be represented by zero.

華夏公益教科書

[編輯 | 編輯原始碼]

Ada 參考手冊

[編輯 | 編輯原始碼]

Ada 質量和風格指南

[編輯 | 編輯原始碼]


Ada 關鍵字
abort else new return
abs elsif not reverse
abstract (Ada 95) end null
accept entry select
access exception of separate
aliased (Ada 95) exit or some (Ada 2012)
all others subtype
and for out synchronized (Ada 2005)
array function overriding (Ada 2005)
at tagged (Ada 95)
generic package task
begin goto parallel (Ada 2022) terminate
body pragma then
if private type
case in procedure
constant interface (Ada 2005) protected (Ada 95) until (Ada 95)
is use
declare raise
delay limited range when
delta loop record while
digits rem with
do mod renames
requeue (Ada 95) xor
華夏公益教科書