You need to use the function that RETURNs the value, not outputs it.
From docs I found for whatever this is,
bp_activity_user_id() X-Ref
Output the activity user ID.
bp_get_activity_user_id() X-Ref
Return the activity user ID.
return: int The activity user ID.
The function you are using echoes the variable, NOT returns it and therefore you can't set a variable with that function. Same for the this function.
bp_activity_comment_user_id() X-Ref
Output the ID of the author of the activity comment currently being displayed.
bp_get_activity_comment_user_id() X-Ref
Return the ID of the author of the activity comment currently being displayed.
return: int|bool $user_id The user_id of the author of the displayed
To use in an assignment, the function has to return a value. That's why your values are always (int)0: the functions you are using have no return value. So, it returns null which is cast to 0.
<?php
$postuser = bp_get_activity_user_id();
$posteduser = bp_get_activity_comment_user_id();
//no need to cast: these functions return integers
if ( $postuser === $posteduser) {
echo 'true';
} else {
echo 'False';