Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equality comparison between numbers with different bases #80

Open
ricted98 opened this issue Apr 28, 2023 · 0 comments
Open

Equality comparison between numbers with different bases #80

ricted98 opened this issue Apr 28, 2023 · 0 comments

Comments

@ricted98
Copy link

set old_value_numeric [examine -radix binary,enumnumeric $signal_name]
set new_value_numeric [expr int(rand()*([expr 2 ** [string length $old_value_numeric]]))]
while {$old_value_numeric == $new_value_numeric && [string length $old_value_numeric] != 1} {
set new_value_numeric [expr int(rand()*([expr 2 ** [string length $old_value_numeric]]))]
}
if {$is_register} {
force -freeze $signal_name $new_value_numeric -cancel $::register_fault_duration
} else {
force -freeze $signal_name $new_value_numeric, $old_value_numeric $::signal_fault_duration -cancel $::signal_fault_duration
}

old_value_numeric is extracted as a binary value while new_value_numeric is stored as a decimal number. As a result, the condition in the while statement $old_value_numeric == $new_value_numeric && [string length $old_value_numeric] != 1 is stuck to false and the command force -freeze interprets old_value_numeric as a decimal value since no base is specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant