Wiki

Changes between Version 1 and Version 2 of Troubleshooting

Show
Ignore:
Timestamp:
05/05/10 10:48:52 (8 years ago)
Author:
Chuck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Troubleshooting

    v1 v2  
    22 
    33Here are some problems people run into when getting started with Cobra and their solution. 
     4 
     5=== Errors about "float" === 
     6 
     7Symptoms include error messages you weren't expecting about method calls and "float" arguments: 
     8{{{ 
     9obj.foo(1.0, 1.0)   # error: Cannot convert... 
     10}}} 
     11Cobra supports fractional values with the types: 
     12 * float32 
     13 * float64 
     14 * float (=float64) 
     15 * decimal (the default) 
     16One 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: 
     17{{{ 
     18@number float64 
     19}}} 
     20Or passing it at the command line: 
     21{{{ 
     22cobra -number:float64 ... 
     23}}} 
     24You can also choose "float32". 
     25 
     26If you only need the occasional float, you can use suffixes like "_f64" and "_f32" (or "_d" for decimal): 
     27{{{ 
     28obj.foo(1.0_f32, 1.0_f32) 
     29}}} 
    430 
    531=== 64-bit vs. 32-bit Clash ===