#!perl use strict; use warnings; use Config; use Math::BigFloat; print qq{Perl $], $^X, archname=$Config{archname}, byteorder=$Config{byteorder} }; my $le = ( $Config{byteorder} =~ qr/^1234/ ) ? 1 : 0; use constant POSITIVE_INFINITY => "\x7f\xf0\x00\x00\x00\x00\x00\x00"; use constant NEGATIVE_INFINITY => "\xff\xf0\x00\x00\x00\x00\x00\x00"; use constant NOT_A_NUMBER => "\x7f\xf8\x00\x00\x00\x00\x00\x00"; # manually if ($le) { print qq{le:} .unpack("d*", reverse POSITIVE_INFINITY); print qq{le:} .unpack("d*", reverse NEGATIVE_INFINITY); print qq{le:} .unpack("d*", reverse NOT_A_NUMBER); } else { print qq{be:} .unpack("d*", POSITIVE_INFINITY); print qq{be:} .unpack("d*", NEGATIVE_INFINITY); print qq{be:} .unpack("d*", NOT_A_NUMBER); } # using Math::BigFloat print qq{mbf:} .Math::BigFloat->binf(); print qq{mbf:} .Math::BigFloat->binf('-'); print qq{mbf:} .Math::BigFloat->bnan(); __END__ # MSWin32 C:\src\perl\infinity>perl -wl infinity.pl Perl 5.008008, C:\Perl\bin\perl.exe, archname=MSWin32-x86-multi-thread, byteorder=1234 le:1.#INF le:-1.#INF le:1.#QNAN mbf:inf mbf:-inf mbf:NaN # darwin $ perl -wl infinity.pl Perl 5.008006, perl, archname=darwin-thread-multi-2level, byteorder=4321 be:inf be:-inf be:nan mbf:inf mbf:-inf mbf:NaN # i386-linux Perl 5.008005, /usr/bin/perl, archname=i386-linux-thread-multi, byteorder=1234 le:inf le:-inf le:nan mbf:inf mbf:-inf mbf:NaN