Wiki

Changes between Version 9 and Version 10 of Troubleshooting

Show
Ignore:
Timestamp:
11/22/10 20:26:42 (7 years ago)
Author:
todd.a
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Troubleshooting

    v9 v10  
    77Symptoms include error messages you weren't expecting about method calls and "float" arguments: 
    88{{{ 
     9#!cobra 
    910obj.foo(1.0, 1.0)   # error: Cannot convert... 
    1011}}} 
     
    1617One of these types has to be the default type for values such as "1.0" and "x/y". Cobra uses "decimal" because it is more accurate with respect to the base-10 numbers people normally work with (e.g., 10%, 1.6). However, some libraries--especially for graphics and games--expect binary floating point numbers. If your application is oriented towards such numbers you can change the default number type by placing this in your code: 
    1718{{{ 
     19#!cobra 
    1820@number float64 
    1921}}} 
    2022Or passing it at the command line: 
    2123{{{ 
     24#!cobra 
    2225cobra -number:float64 ... 
    2326}}} 
     
    2629If you only need the occasional float, you can use suffixes like "_f64" and "_f32" (or "_d" for decimal): 
    2730{{{ 
     31#!cobra 
    2832obj.foo(1.0_f32, 1.0_f32) 
    2933}}} 
     
    4044or with a directive in a source file: 
    4145{{{ 
     46#!cobra 
    4247@args -sharp-args:"/platform:x86" 
    4348}}}