encode num bits now matches stan's