print using questions

New to FreeBASIC? Post your questions here.
12val12newakk
Posts: 20
Joined: Nov 14, 2019 17:04

print using questions

Postby 12val12newakk » Jul 02, 2020 15:02

How print 208 585 224 782
As 208.5E9
need E9 (gigapaskal)
This
print using "Modul_U= ###.# ^"; Modul_U
printing parasite "%" befor
srvaldez
Posts: 2506
Joined: Sep 25, 2005 21:54

Re: print using questions

Postby srvaldez » Jul 02, 2020 15:34

try
print using "####.#^^^^";208585224782
fxm
Posts: 9912
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: print using questions

Postby fxm » Jul 02, 2020 16:07

The exponent-part consists of from three to five ^ that must immediately follow the decimal-part:
^^^ for the exponent part on one digit (after the sign): E+/-#
^^^^ for the exponent part on two digits (after the sign): E+/-##
^^^^^ for the exponent part on three digits (after the sign): E+/-###

I can update the documentation.
[edit]
DONE:
KeyPgPrintusing → fxm [updated syntax for exponential notation]
Last edited by fxm on Jul 02, 2020 18:13, edited 2 times in total.
badidea
Posts: 2141
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: print using questions

Postby badidea » Jul 02, 2020 16:57

12val12newakk wrote:How print 208 585 224 782
As 208.5E9
need E9 (gigapaskal)
This
print using "Modul_U= ###.# ^"; Modul_U
printing parasite "%" befor

Code: Select all

#include "string.bi"

function formatE9(byval number as double) as string
   number /= 1e9
   return format(number, "0.0") & "E9"
end function

dim as double number = 208585224782

print formatE9(number / 100)
print formatE9(number / 10)
print formatE9(number) & " <--"
print formatE9(number * 10)
print formatE9(number * 100)

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 4 guests