Recent

Author Topic: Round numbers  (Read 1192 times)

hellohello234

  • Newbie
  • Posts: 3
Round numbers
« on: June 05, 2021, 05:12:27 pm »
Can someone explain why the decimal numbers won't round? I can't figure it out ://

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Round numbers
« Reply #1 on: June 05, 2021, 05:25:18 pm »
You did not give enough information, specify your input and output.

g8 is not assigned a value.

Did you look here:
https://www.freepascal.org/docs-html/rtl/system/round.html
« Last Edit: June 05, 2021, 05:26:53 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

hellohello234

  • Newbie
  • Posts: 3
Re: Round numbers
« Reply #2 on: June 05, 2021, 05:39:30 pm »
You did not give enough information, specify your input and output.

g8 is not assigned a value.

Did you look here:
https://www.freepascal.org/docs-html/rtl/system/round.html

Yeah I figured it out hahaa, i meant to put g8:= round(g7) ,, but it still doesn't work :(

Bart

  • Hero Member
  • *****
  • Posts: 5275
    • Bart en Mariska's Webstek
Re: Round numbers
« Reply #3 on: June 05, 2021, 07:37:21 pm »
Define: does not work.
It does not round at all (so 3.14159 stays 3.14159) or you see digits behind the decimal point (3.14159 becomes 3.0000000000000001 or 2.9999999999999).
The latter is because you assign the result to a double and wether or not you see decimals depends on the method you use to display that double.

Bart

 

TinyPortal © 2005-2018