Finding absolute difference in orientation

I’m trying to create a method to check the difference in orientations between 2 parts in a specific way. The idea is to check if 1 part has more than a 90 degree difference from the other regardless of direction, though given how orientation is handled, this is somewhat difficult. At some point in orientation, it just swaps to a negative number, and depending on how different the 2 numbers are, they can get too big quite quickly. Ideally, the number returned from the check shouldn’t ever get above 180.

A couple of methods I've tried so far, but don't work as I'd like. In these examples, I'm purely trying to find the difference in the Y rotation.

Example 1:

local A,B = PartA.Orientation.Y,PartB.Orientation.Y
local Diff = math.abs(A-B)

Example 2:

local _,A,_ = PartA.CFrame:ToOrientation()
local _,B,_ = PartB.CFrame:ToOrientation()
	A = math.abs(math.deg(A))
	B = math.abs(math.deg(B))
local Diff = math.abs(A-B)

Example 3:

local A,B = math.abs(PartA.Orientation.Y),math.abs(PartB.Orientation.Y)
	print("A:",A)
	print("B:",B)
	local Diff = math.abs(A-B)

I’m probably just being a bit silly and this is easy to do, but I can’t figure it out in a consistent manner.

You can calculate the angle between both CFrames look-/up-/right vector to see if the angle for any of the 3 axis is too great.
The formula for calculating the angle between 2 3d unit vectors can be found online.