in reply to Is there a better way to call fe(get|set)round?
package Somename; use Math::BigFloat; sub new { my $class = shift; my $self = bless {}; $self -> { underlying } = Math::BigFloat -> new( @_ ); return ( $self, $class ); } sub fsetround { # e.g. $obj -> fsetround( mode => 'FE_DOWNWARD' ); my $self = shift; my %opt = @_; while ( my ( $k, $v ) = each %opt ) { $self -> { $k } = $v; } # set defaults here e.g. for round by default # to 17 digits from the left $self -> { scale } ||= 17; } sub fgetround my $self = shift; if ( $self -> { mode } eq 'FE_DOWNWARD' ) { my $bf = $self -> { underlying }; return $bf -> ffround( -( $self -> { scale } ) ); } # elsif ... # etc. for the other features of fenv }
^M Free your mind!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Is there a better way to call fe(get|set)round?
by BrowserUk (Patriarch) on Jul 02, 2007 at 13:26 UTC | |
by HollyKing (Pilgrim) on Jul 04, 2007 at 18:56 UTC |