## Display Decimal Places

New to FreeBASIC? Post your questions here.
baserunner0723
Posts: 1
Joined: Aug 14, 2018 21:41

### Display Decimal Places

I know a little about basic but i can't figure out how to display decimals.

Code: Select all

`dim fr as integer dim fe as integer dim ama as integerdim ima as integerdim eff as integerdim choice as integerprint "What Simple Machine do you want to calculate MA for?"print "1. Inclined Plane"input "Choice: " , choice if choice = 1 then    dim L as integer    dim H as integer    input "What is the Length of the ramp? " , L    input "What is the Height of the ramp? " , H    input "What is Fr? " , fr    input "What is Fe? " , fe    ima=L/H    ama=fr/fe    eff=(ama/ima)*100    cls     print "Results"    print "IMA: " ; ima ; ":1"    print "AMA: " ; ama ; ":1"    print "Efficiency: " ; eff ; "%"    sleependif sleep`
MrSwiss
Posts: 2996
Joined: Jun 02, 2013 9:27
Location: Switzerland

### Re: Display Decimal Places

Hi,

welcome to the forum.

Integers are "whole numbers" only, if you want decimals you'll have to use floats:
Single (precision) 32 bit, or Double (precision) 64 bit.
See: Wikipedia for detailed info.

Code: Select all

`dim as single fr, fe, ama, ima, eff, choiceprint "What Simple Machine do you want to calculate MA for?"print "1. Inclined Plane"input "Choice: " , choiceif choice = 1 then    dim L as integer    dim H as integer    input "What is the Length of the ramp? " , L    input "What is the Height of the ramp? " , H    input "What is Fr? " , fr    input "What is Fe? " , fe    ima=L/H    ama=fr/fe    eff=(ama/ima)*100    cls    print "Results"    print "IMA: " ; ima ; ":1"    print "AMA: " ; ama ; ":1"    print "Efficiency: " ; eff ; "%"    sleependifsleep`
paul doe
Posts: 886
Joined: Jul 25, 2017 17:22
Location: Argentina

### Re: Display Decimal Places

Hi, baserunner0723. Welcome to the forum.

Be sure to also check the Documentation forum. You'll find invaluable information there, including a PDF manual to help you get started with FreeBasic.

Cheers!