(adsbygoogle = window.adsbygoogle || []).push({}); 3 Simple questions -- Math for ABS(), Round()

To find the absolute value of a number you can use this

((x ^ 2) ^ 0.5)

To round a number up you can use this

-(((-x - 1) - ((-x - 1) % 1)) + 1)

To round a number down

(x - (x % 1))

Are there better ways to do this? The middle one is the one I'm thinking should somehow be shorter

This is for a program I'm making so it needs to be in normal text format please

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# 3 Simple questions - Math for ABS(), Round()

Loading...

Similar Threads - Simple questions Math | Date |
---|---|

Simple mathematica question | Feb 2, 2017 |

Simple Big O analysis question | Feb 3, 2014 |

Simple C++ method question (overloading?) | Mar 17, 2012 |

Simple Question about C++ classes | Mar 14, 2011 |

Simple python question | Mar 26, 2010 |

**Physics Forums - The Fusion of Science and Community**