File: Float64.pm

package info (click to toggle)
libdata-compactreadonly-perl 0.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: perl: 990; sh: 3; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 790 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package Data::CompactReadonly::V0::Scalar::Float64;
our $VERSION = '0.1.0';

use warnings;
use strict;
use base 'Data::CompactReadonly::V0::Scalar::Huge';

# FIXME this uses pack()'s d format underneath, which exposes the
# native machine floating point format. This is not guaranteed to
# actually be IEEE754. Yuck. Need to find a comprehensible spec and
# a comprehensive text suite and implement my own.
use Data::IEEE754 qw(unpack_double_be pack_double_be);

sub _create {
    my($class, %args) = @_;
    my $fh = $args{fh};
    $class->_stash_already_seen(%args);
    print $fh $class->_type_byte_from_class().
              pack_double_be($args{data});
    $class->_set_next_free_ptr(%args);
}

sub _decode_word {
    my($class, $word) = @_;
    return unpack_double_be($word);
}

1;