Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8963407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:20:53+00:00 2026-06-15T16:20:53+00:00

IEEE754 supports the negative zero. But this code a := -0.0 fmt.Println(a, 1/a) outputs

  • 0

IEEE754 supports the negative zero.
But this code

a  := -0.0
fmt.Println(a, 1/a)

outputs

0 +Inf

where I would have expected

-0 -Inf

Other languages whose float format is based on IEEE754 let you create negative zero literals

Java :

float a = -0f;
System.out.printf("%f %f", a, 1/a); // outputs "-0,000000 -Infinity"

C# :

var a = -0d;
Console.WriteLine(1/a); // outputs "-Infinity"

Javascript :

​var a = -0;
console.log(a, 1/a);​ // logs "0 -Infinity"

But I couldn’t find the equivalent in Go.

How do you write a negative zero literal in go ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:20:54+00:00Added an answer on June 15, 2026 at 4:20 pm

    There is a registered issue.

    And it happens to give a kind of solution :

    a := math.Copysign(0, -1)
    

    It’s not so bad as it obviously refers to the standard copysign function defined by IEEE754.

    But this means you need to import a package and this still looks much too heavy for the (admittedly minor and rare) need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the purposes of this question, I do not have the ability to use
In MATLAB (r2009b) I have a uint32 variable containing the value 2147484101. This number
I have a IEEE754 Double precision 64-bit binary string representation of a double number.
i want to test some code to make sure it handles NAN , INF
In my code I have a class named membrane with a function named exciteMod()
I would like to have the closest number below 1.0 as a floating point.
So, I have the following code: a = new Float64Array([num]) b = new Uint8Array(a.buffer)
I wrote this code to do the IEEE 754 floating point arithmetic on a
Refreshing on floating points (also PDF ), IEEE-754 and taking part in this discussion
What are some good do-s and don't-s for floating point arithmetic (IEEE754 in case

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.