|
Post by adamkonrad on Feb 6, 2023 16:31:53 GMT -5
Hi, is there a way to force the use of scientific notation?, preferable with whole number before decimal point
when marking the tics of the grid for example could be usefull
or in 'using' function
or is it necessery to code upone need
adam
|
|
|
Post by tsh73 on Feb 6, 2023 18:18:48 GMT -5
I have some old code Have look - will it do?
n = 123.456 print n, usingS$(n,3) print n, usingS$(n,0) n = 7623.456 print n, usingS$(n,0) n = 123.456/1e6 print n, usingS$(n,3) n = -7623.456 print n, usingS$(n,0) n = -123.456/1e6 print n, usingS$(n,3) n = 1.456464 print n, usingS$(n,3) n = 1.4 print n, usingS$(n,3) n = 0.14 print n, usingS$(n,3) n = 0.014 print n, usingS$(n,3) n = 0 print n, usingS$(n,3) n = 1000 print n, usingS$(n,3) n = 99993 print n, usingS$(n,3) n = 99994 print n, usingS$(n,3) n = 99995 print n, usingS$(n,3) n = 99996 print n, usingS$(n,3) n = 99999 print n, usingS$(n,3)
function usingS$(n,prec) if n = 0 then usingS$="0e+0":exit function fmt$ = "#"+left$(".",prec>0)+left$("#################",prec) 'fmt of mantissa s$=left$("-",n<0) n=abs(n) log10=log(n)/log(10) e=int(log10)-(log10<0) 'QB like INT. Makes mantissa for negative exponents start from digit (not 0 as JB do) p=10^e if left$(using(fmt$,n/p),1)="%" then p=p*10:e = e+1 usingS$=s$+using(fmt$,n/p) +"e"+left$("+",e>0) +str$(e) 'Excel always shows "+" for exponent End function
|
|
|
Post by adamkonrad on Feb 7, 2023 1:17:08 GMT -5
more than adequate works like a charm
a very usefull function,
thank you very much
|
|