Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Positive to negative
#1
Hello, i need to know how can i tranform a positive number in a negative number in Python.
With the inverse effect of "abs()".
If someone can help me i appreciate.
Reply
#2
-
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
multiply it by -1
Recommended Tutorials:
Reply
#4
Yeah but if the number is negative, it continue negative. Like "abs(-1) = 1 and abs(1) = 1".
Reply
#5
-abs(x)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#6
(Mar-13-2019, 07:35 PM)ichabod801 Wrote: -abs(x)
i didnt even know about that Doh
Recommended Tutorials:
Reply
#7
Thank you very much, solved my problem.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cmath.rect accepts a negative modulus JMB 2 328 Jan-17-2024, 08:00 PM
Last Post: JMB
  Positive integral solutions for Linear Diophantine Equation august 4 1,236 Jan-13-2023, 09:48 PM
Last Post: Gribouillis
  How to do bar graph with positive and negative values different colors? Mark17 1 5,123 Jun-10-2022, 07:38 PM
Last Post: Mark17
  is there any tool to convert negative base to int? Skaperen 7 2,395 May-27-2022, 07:30 AM
Last Post: Gribouillis
  Regex: positive lookbehind Secret 2 1,996 Sep-21-2020, 12:59 AM
Last Post: snippsat
  Def code does not work for negative integers. doug2019 1 1,906 Oct-31-2019, 11:00 PM
Last Post: ichabod801
  offset can not be negative in File.seek()? jollydragon 6 6,982 Sep-28-2019, 03:08 AM
Last Post: jollydragon
  Python regex with negative set of characters multiline sonicblind 2 3,390 Jul-30-2018, 08:43 PM
Last Post: sonicblind
  negative to positive slices Skaperen 3 3,637 Jan-29-2018, 05:47 AM
Last Post: Skaperen
  get positive number from a list if there's the same number but negative haye 14 7,504 Nov-08-2017, 05:59 AM
Last Post: ineedastupidusername

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020