© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
5 replies
novaleaf

how to avoid "-0" when converting float to string?

when I convert floats to string like in this example, often I get "-0" as a value. Does anyone know a simple way to convert these to positive zero?
    public static string _Serialize(this Vector3 value)
    {
        return $"{value.X}, {value.Y}, {value.Z}";
    }
    public static string _Serialize(this Vector3 value)
    {
        return $"{value.X}, {value.Y}, {value.Z}";
    }


this is for serialization purposes, so I'd like to avoid some heavy checks just to avoid -0
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ how to avoid string.Join with empty strings?
C#CC# / help
3y ago
❔ error when converting string to long
C#CC# / help
3y ago
✅ Converting string to DateTimeOffset
C#CC# / help
2y ago