You could play code golf and end up with something like: &# 44-(Math.sqrt.(x^2)/x) x
44 is the ascii char for - 43 is the ascii char for + x is your value There's probably a syntax error in there. And it will absolutely fail with a division by 0. You didn't specify what you wanted for 0. Both -0 and +0 always seem weird to me. Don't get me started about 12:00pm. I don't know why you want to save cycles in 2021 with a bit of logic, but I bet you could make something work like this with a little polish. On Sun, Feb 21, 2021 at 9:35 AM D R <[email protected]> wrote: > If the number is negative, it will print a "-" in front of the number. > > Despite looking through Python formatting pages from searches for Python > Formatting, I cannot see that there is a provision to force a "+" in > front of a number no matter what. > > For example: > > -23.7 is always given if negative, > > 45.2 is given but I'd like +45.2 > > Is there a formatting character to do this? I guess a long logical > string to determine if the value is greater than zero, then toggle to > print "+" if true, but that seems more than what I want to waste CPU > cycles. I was just hoping that some character had been assigned to > force a +. > > > Dale > > > -- > You received this message because you are subscribed to the Google Groups > "weewx-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/weewx-user/77c84243-abb7-2e4e-19a1-876b6ecdce39%40gmail.com > . > -- Peter Quinn (415)794-2264 -- You received this message because you are subscribed to the Google Groups "weewx-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/CAA1SM22Ebta8NF7crh2sNFq1C%2BLUf8to1UyEXMOj%2BT_Km2UXZQ%40mail.gmail.com.
