@@ -1352,6 +1352,70 @@ of the program before it's adapted to fit the constraints of the
1352
1352
Real Numeric Types
1353
1353
------------------
1354
1354
1355
+ In the Introduction to Ada course, we talked about
1356
+ :ref: `floating-point <Intro_Ada_Floating_Point_Types >` and
1357
+ :doc: `fixed-point </courses/intro-to-ada/chapters/fixed_point_types >` types.
1358
+ In Ada, these two categories of numeric types belong to the so-called *real
1359
+ types *. In very simple terms, we could say that real types are the ones whose
1360
+ objects we could assign
1361
+ :ref: `real numeric literals <Adv_Ada_Numeric_Literals >` to. For example:
1362
+
1363
+ .. code :: ada run_button project=Courses.Advanced_Ada.Data_Types.Numerics.Real_Numeric_Types.Universal_And_Real_Numeric_Types
1364
+
1365
+ procedure Show_Real_Numeric_Object is
1366
+ V : Float;
1367
+ begin
1368
+ V := 2.3333333333;
1369
+ -- ^^^^^^^^^^^^
1370
+ -- real numeric literal
1371
+ end Show_Real_Numeric_Object;
1372
+
1373
+ Note that we shouldn't confuse real numeric types with
1374
+ :ref: `universal real types <Adv_Ada_Universal_Real_Integer >`. Even though we
1375
+ can assign a named number of universal real type to an object of a real type,
1376
+ these terms refer to very distinct concepts. For example:
1377
+
1378
+ .. code :: ada compile_button project=Courses.Advanced_Ada.Data_Types.Numerics.Real_Numeric_Types.Universal_And_Real_Numeric_Types
1379
+
1380
+ package Universal_And_Real_Numeric_Types is
1381
+
1382
+ Pi : constant := 3.1415926535;
1383
+ -- ^^^^^^^^^^^^
1384
+ -- universal real type
1385
+
1386
+ V : Float := Pi;
1387
+ -- ^^^^^
1388
+ -- real type
1389
+ -- (floating-point type)
1390
+ --
1391
+
1392
+ end Universal_And_Real_Numeric_Types;
1393
+
1394
+ In this example, :ada: `Pi ` is a named number of universal real type, while
1395
+ :ada: `V ` is an object of real type |mdash | and of floating-point type, to be
1396
+ more precise.
1397
+
1398
+ Note that both real types and universal real types are implicitly derived from
1399
+ the :ref: `root real type <Adv_Ada_Root_Types >`, which we already discussed in
1400
+ another chapter.
1401
+
1402
+ In the next two sections, we discuss further details about
1403
+ floating-point and
1404
+ fixed-point types.
1405
+
1406
+ .. todo ::
1407
+
1408
+ Add link to section on floating-point types <Adv_Ada_Floating_Point_Types>
1409
+ when it has become available!
1410
+
1411
+ .. todo ::
1412
+
1413
+ Add link to section on fixed-point types <Adv_Ada_Fixed_Point_Types>
1414
+ when it has become available!
1415
+
1416
+ .. admonition :: In the Ada Reference Manual
1417
+
1418
+ - :arm22: `3.5.6 Real Types <3-5-6> `
1355
1419
1356
1420
1357
1421
.. ::
0 commit comments