/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/libvqdr/value/value_token.vala

  • Committer: Gustav Hartvigsson
  • Date: 2021-09-09 15:40:16 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20210909154016-0hm69n49w2slfky5
added more testes for the parser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
    //return new VariableValueToken (name, position);
16
16
    return null;
17
17
  }
18
 
  
19
 
  public static long parse_raw_value (string str) {
20
 
    long ret_val = 0;
21
 
    int i_of_dot = str.index_of_char ('.');
22
 
    if (i_of_dot >= 0) {
23
 
    
24
 
      // Get the decimal value from the string, if such a thing exists.
25
 
      if ((str.length - 1 > i_of_dot)) {
26
 
        ret_val = long.parse ((str + "000").substring (i_of_dot + 1));
27
 
        
28
 
      }
29
 
      
30
 
      // Normalise the digits.
31
 
      while (ret_val > Token.VALUES_PRECISION_FACTOR) {
32
 
        ret_val = ret_val / 10;
33
 
      }
34
 
      
35
 
      // Add intiger value
36
 
      ret_val = ret_val + (long.parse ("0" + str.substring (0, i_of_dot)) * Token.VALUES_PRECISION_FACTOR);
37
 
    } else {
38
 
      ret_val = long.parse (str) * Token.VALUES_PRECISION_FACTOR;
39
 
    }
40
 
    return ret_val;
41
 
  }
42
 
  
43
 
  
44
18
}