### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: Round numbers  (Read 855 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: 1037
• 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.0
macOS 10.13.6: Lazarus 2.0.12 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.12 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.12 (64 bit on VBox)

#### jamie

• Hero Member
• Posts: 4742
##### Re: Round numbers
« Reply #2 on: June 05, 2021, 05:33:44 pm »
More than likely it's all those digits that are being displayed!
The only true wisdom is knowing you know nothing

#### hellohello234

• Newbie
• Posts: 3
##### Re: Round numbers
« Reply #3 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: 4345
##### Re: Round numbers
« Reply #4 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