2 scalar.cc -- implement Scalar
4 source file of the Flower Library
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "rational.hh"
14 Scalar::Scalar (Rational r)
19 Scalar::operator Rational ()
25 Scalar::to_rat () const
27 int p = index_i ('/');
31 String s2 = right_str (length_i ()-p-1);
32 String s1 = left_str (p);
34 return Rational (s1.value_i (), s2.value_i ());
38 Scalar::isdir_b () const
40 int conv = length_i ();
44 conv = sscanf (strh_.ch_C (), "%ld", &l);
45 conv = conv && (l >= -1 && l <= 1);
51 Scalar::isnum_b () const
57 conv = sscanf (strh_.ch_C (), "%lf", &l);
59 return length_i () && conv;
62 Scalar::operator Real()
74 Scalar::operator int ()
89 Scalar::operator bool () const
95 Scalar::to_bool () const
102 if (u.upper_str () == "FALSE")