elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  como poner los decimales correctamente?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: como poner los decimales correctamente?  (Leído 207 veces)
Crumenal

Desconectado Desconectado

Mensajes: 1


Ver Perfil
como poner los decimales correctamente?
« en: Ayer a las 09:30 »

Código:
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
   double exa = 1E18;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<< setw(20)<<"Decimal"<<"|"<<setw(15)<<"Standard form"<<"|"<<setw(8)<<"prefex"<<"|"<<setw(5)<<"Abbreviation"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<exa<<"|"<<setw(8)<<"exa"<<"|"<<setw(10)<<"E"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E15<<"|"<<setw(8)<<"peta"<<"|"<<setw(10)<<"P"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E12<<"|"<<setw(8)<<"tera"<<"|"<<setw(10)<<"T"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E9<<"|"<<setw(8)<<"giga"<<"|"<<setw(10)<<"G"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E6<<"|"<<setw(8)<<"mega"<<"|"<<setw(10)<<"M"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E3<<"|"<<setw(8)<<"kilo"<<"|"<<setw(10)<<"k"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E2<<"|"<<setw(8)<<"hecto"<<"|"<<setw(10)<<"h"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E1<<"|"<<setw(8)<<"deca"<<"|"<<setw(10)<<"da"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1<<"|"<<setw(8)<<"deci"<<"|"<<setw(10)<<"d"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-1<<"|"<<setw(8)<<"centi"<<"|"<<setw(10)<<"c"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-3<<"|"<<setw(8)<<"milli"<<"|"<<setw(10)<<"m"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-6<<"|"<<setw(8)<<"micro"<<"|"<<setw(10)<<"?"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-9<<"|"<<setw(8)<<"nano"<<"|"<<setw(10)<<"n"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<1E-12<<"|"<<setw(8)<<"pico"<<"|"<<setw(10)<<"p"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<"1E-15"<<"|"<<setw(8)<<"femto"<<"|"<<setw(10)<<"f"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;
   cout<<"|"<<setw(20)<<fixed<<setprecision(0)<<exa<<"|"<<setw(15)<<left<<scientific<<"1E-18"<<"|"<<setw(8)<<"atto"<<"|"<<setw(10)<<"a"<<"|"<<endl;
   cout<<"+"<< setw(20)<<setfill ('-')<<""<<"+"<<setw(15)<<setfill ('-')<<""<<"+"<<setw(20)<<setfill ('-')<<""<<"+"<<endl;


   return 0;

}




En línea

Mr.Byte


Desconectado Desconectado

Mensajes: 339



Ver Perfil
Re: como poner los decimales correctamente?
« Respuesta #1 en: Ayer a las 15:55 »

Lo que sale de consola, para hacerlo un poco mas claro



+--------------------+---------------+--------------------+
|-------------Decimal|--Standard form|--prefex|Abbreviation|
+--------------------+---------------+--------------------+
|-1000000000000000000|1e+18----------|exa-----|E---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+15----------|peta----|P---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+12----------|tera----|T---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+09----------|giga----|G---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+06----------|mega----|M---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+03----------|kilo----|k---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+02----------|hecto---|h---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e+01----------|deca----|da--------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1--------------|deci----|d---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e-01----------|centi---|c---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e-03----------|milli---|m---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e-06----------|micro---|?---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e-09----------|nano----|n---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1e-12----------|pico----|p---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1E-15----------|femto---|f---------|
+--------------------+---------------+--------------------+
|1000000000000000000-|1E-18----------|atto----|a---------|
+--------------------+---------------+--------------------+



En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
ayuda como pasar numeros con decimales a fraccion
Programación Visual Basic
andrer03 5 18,012 Último mensaje 23 Marzo 2009, 01:10 am
por andrer03
Como limitar los decimales en un textbox.
Programación Visual Basic
oJosLoCos 3 14,252 Último mensaje 15 Diciembre 2009, 16:09 pm
por oJosLoCos
Format - ¿Cómo conseguir 2 decimales SIN redondeo?(Solucionado)
Programación Visual Basic
karmany 9 44,236 Último mensaje 18 Marzo 2018, 03:33 am
por fabianmoyata
¿Cómo guardar en archivo .txt con 2 decimales?
Programación C/C++
Juancho25 3 4,098 Último mensaje 4 Noviembre 2012, 02:22 am
por rir3760
Como quitar decimales en java?
Java
Angel wing 1 4,575 Último mensaje 21 Octubre 2017, 00:16 am
por Orubatosu
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines