# Hexadecimal/Octal literals are parsed as 0 #71

Closed
opened this Issue Dec 15, 2015 · 1 comment

Projects
None yet
2 participants

### einarjohan commented Dec 15, 2015

 A simple example: ``````var 0..255: hex_variable; var 0..255: dec_variable; constraint (hex_variable == 0xFF); constraint (dec_variable == 255); solve :: int_search([hex_variable, dec_variable], first_fail, indomain_random, complete) satisfy; `````` Running this through MiniZinc (2.0.6 and 2.0.10 tested on Linux) and fzn-gecode yields: ``````dec_variable = 255; hex_variable = 0; ---------- `````` A slightly more involved example that demonstrates the same failure for octals, as well as par-variables: ``````var 0..255: hex_variable; var 0..255: dec_variable; var 0..255: oct_variable; par int: hex_constant = 0xFF; par int: oct_constant = 0o377; par int: dec_constant = 255; var 0..1: trivial_hex; constraint (hex_variable == 0xFF); % Results in 0 constraint (dec_variable == 255); % Results in 255 constraint (oct_variable == 0o377); % Results in 0 constraint (trivial_hex == 0x1); % Results in 0 % These pass, presumably because we use literals here as well. constraint (dec_constant == 255); constraint (hex_constant == 0xFF); constraint (oct_constant == 0o7777); % These fail, as the constants evaluate to 0 for hex/oct. %constraint (dec_constant == hex_constant); %constraint (dec_constant == oct_constant); solve :: int_search([hex_variable, oct_variable, dec_variable, trivial_hex], first_fail, indomain_random, complete) satisfy; `````` Which yields: ``````dec_variable = 255; hex_variable = 0; oct_variable = 0; trivial_hex = 0; ---------- `````` I double checked against the MiniZinc specification, and according to 7.3.4 there this should be valid, and the three constants should be equivalent (except for trivial_hex, which should be 1)
Member

### guidotack commented Dec 15, 2015

 Thanks, that's an embarrassing one! (And obviously that part of the code wasn't tested at all.)

### guidotack added a commit that referenced this issue Dec 15, 2015

``` Fix parsing of hex and octal literals. Fixes #71. ```
``` dc92c71 ```