Variable size/Set: Difference between revisions
Content added Content deleted
(Perl) |
m (Switch to header template) |
||
Line 2: | Line 2: | ||
Demonstrate how to specify the minimum size of a variable or a data type. |
Demonstrate how to specify the minimum size of a variable or a data type. |
||
== |
=={{header|Ada}}== |
||
[[Category:Ada]] |
|||
type Response is (Yes, No); -- Definition of an enumeration type with two values |
type Response is (Yes, No); -- Definition of an enumeration type with two values |
||
for Response'Size use 1; -- Setting the size of Response to 1 bit, rather than the default single byte size |
for Response'Size use 1; -- Setting the size of Response to 1 bit, rather than the default single byte size |
||
== |
=={{header|Perl}}== |
||
[[Category:Perl]] |
|||
I suppose you could use vec() or similar to twiddle a single bit. The thing is, as soon as you store this in a variable, the SV (the underlying C implementation of the most simple data type) already takes a couple dozen of bytes. |
I suppose you could use vec() or similar to twiddle a single bit. The thing is, as soon as you store this in a variable, the SV (the underlying C implementation of the most simple data type) already takes a couple dozen of bytes. |
||
Revision as of 05:52, 13 November 2007
![Task](http://static.miraheze.org/rosettacodewiki/thumb/b/ba/Rcode-button-task-crushed.png/64px-Rcode-button-task-crushed.png)
You are encouraged to solve this task according to the task description, using any language you may know.
Demonstrate how to specify the minimum size of a variable or a data type.
Ada
type Response is (Yes, No); -- Definition of an enumeration type with two values for Response'Size use 1; -- Setting the size of Response to 1 bit, rather than the default single byte size
Perl
I suppose you could use vec() or similar to twiddle a single bit. The thing is, as soon as you store this in a variable, the SV (the underlying C implementation of the most simple data type) already takes a couple dozen of bytes.
In Perl, memory is readily and happily traded for expressiveness and ease of use.