Message: 1 Date: Mon, 05 Dec 2005 09:29:56 +0100 From: Raphael Collet <[EMAIL PROTECTED]> Subject: Re: Oz Newbie: Pattern Matching and Type Conversion To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Raph, Maximilian Wilson wrote: > On 12/2/05, Anthony Borla <[EMAIL PROTECTED]> wrote: >> I *do* miss implict type conversion behaviour [e.g. C 'type >> promotions'], and have been bitten [numerous times] by >> simple code such as: >> >> <float> / <int> >> > > The thing about type conversions is that they can be > lossy (i.e. lose information), and worse, they're > silently lossy. > > For the sake of completeness, the picture is even worse > in Mozart than in C. In C all integers convert to valid floats. > This is not the case in Mozart, since floats have fixed size > in memory, while integers don't. So some integers are > rounded to Inf! > > I stepped into that problem with my Minesweeper. > The program counts the total number of solutions of a > given problem with integers. This number is printed as > a float, just because of the simpler format. I was once > surprised when it printed "Inf", because I just tried a > problem with more than 10^100 solutions ;-) The > "counting" part of the program simply does not work > with floats! > So are you saying that integer arithmetic is arbitrary precision-based, and floats are hardware-mapped ? Cheers, Anthony Borla _________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
