是否可以声明具有无限上限的Ada范围? [英] Is it possible to declare Ada range with unlimited upper bound?

查看:87
本文介绍了是否可以声明具有无限上限的Ada范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想声明Ada中记录类型的速度范围。以下内容不起作用,但是有办法使它起作用吗?

I would like to declare a speed range for a record type in Ada. The following won't work, but is there a way to make it work?

   --Speed in knots, range 0 to unlimited
   Speed : float Range 0.0 .. unlimited ;

我只希望该数字为零...

I just want a zero positive value for this number...

推荐答案

您不能-但由于 Speed 的类型为 Float ,则其值不能超过 Float'Last

You can't -- but since Speed is of type Float, its value can't exceed Float'Last anyway.

Speed : Float range 0.0 .. Float'Last;

(您可能想声明一个显式类型或子类型。)

(You'll likely want to declare an explicit type or subtype.)

这篇关于是否可以声明具有无限上限的Ada范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆