[nem-bug] [Nemerle 0000834]: Derive floating point literal's type from its precision

feedback at nemerle.org feedback at nemerle.org
Sun Jan 21 22:29:10 CET 2007


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=834> 
======================================================================
Reported By:                AstralStorm
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   834
Category:                   Language Feature
Reproducibility:            always
Severity:                   feature
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             01-21-2007 22:18 CET
Last Modified:              01-21-2007 22:29 CET
======================================================================
Summary:                    Derive floating point literal's type from its
precision
Description: 
Currently, floating point literals are always of type System.Double.
This makes them awkward to use as parameters to many functions accepting
System.Single (AKA float), as System.Double is not convertible to
System.Single
(the other way around the conversion is possible)

In my opinion, the literal should be the "smallest" type having required
precision.
======================================================================

----------------------------------------------------------------------
 nazgul - 01-21-07 22:29 
----------------------------------------------------------------------
Hmm, you can specify the exact type of literals:

$ cat t.n

def f ['a] (val : 'a) {
  System.Console.WriteLine ("{0} - {1}", val.GetType (), val);    
}

f (1b);
f (1d);
f (1f);
f (1m);
f (1s);
f (1u);

nazgul at mordor ~/nemerle/ncc/testsuite
$ ./run t.n
____________________________________________________________

System.Byte - 1
System.Double - 1
System.Single - 1
System.Decimal - 1
System.Int16 - 1
System.UInt32 - 1

Though you are right... probably we should do similar heuristics as with
integral numbers.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
01-21-07 22:18 AstralStorm    New Issue                                    
01-21-07 22:29 nazgul         Note Added: 0001629                          
======================================================================




More information about the bugs mailing list