ipv6 prefix calculation in script

Trying to hack together quick firewall script in ROS.
I can easily get ipv6 address of an interface, with:

:local ipv6addr [/ipv6 address get [find where global] address];

or with

:local ipv6addr [/ipv6 address get [find where global interface=bridge1 ] address];

And it spits me out and IP address in (usual) format: xxxx:yyy:zzzz:wwww::q/64

But now I’m a bit in trouble of doing subnet calculation inside script to find the actual network address.
Any tips how I could do it inside ROS?