Problem Adjusting Texture Value in Shader

I’m trying to break a texture down to two separate outputs, one that has only the values from 0 to .5, the other from .5 to 1.

In Photoshop I can accomplish that using levels, by adjusting the values in low and in high separately.

As far as I know, the math for that would be to multiply my input by two and clamp at 1, and for the other one, multiply by two, subtract one, and then clamp.

But the results are far from what I was expecting.

Can someone tell me what I’m doing wrong?

Thanks a lot!

I did some more tests and it looks like I need to import the image as linear, do my math, and then convert to sRGB in the shader.
But I was under the impression that all math was done in linear space, regardless of how the texture was imported… Therefore I could keep my color textures as sRGB.
Am I wrong?