Questions tagged as 'tipagem'

2
answers

Why is my function concatenating instead of adding the numbers?

I'm learning JavaScript and I'm breaking my head with this code I created. Why is my function concatenating instead of adding up the numbers I store in variables? <!DOCTYPE html> <html> <head> <title>Aula 05 Java Sc...
asked by 30.04.2016 / 21:55
2
answers

Default to typify errors / exceptions?

As far as I know, JavaScript has no error typing. In C # and Java, it is possible to do things like: try { /* .. snip .. */ } catch (FooException foo) { /* .. snip .. */ } catch (BarException bar) { /* .. snip .. */ } catch (Not...
asked by 25.09.2014 / 18:26
1
answer

PHP 7 - Why does a method that returns the primitive type String, does not generate error when returning a Boolean value?

PHP 7 - Why does a method that returns the String primitive does not generate an error returning a Boolean value? <?php class Foo { public function bar() : string { return true; } } $Foo = new Foo(); echo $Foo->b...
asked by 08.08.2018 / 18:42
2
answers

Why does not Java add the numbers into expression? [duplicate]

public class Teste { public static void main(String[] args) { int x = 0; int y = 1; int z = 2; System.out.print(x + y + z); } } This returns: 3 public class Teste { public static void main(String[] a...
asked by 20.04.2018 / 19:20
2
answers

How to check if a variable is float, decimal or integer in JavaScript? [duplicate]

I tried with typeof() , but it only returns me if it's a number, string , etc. It would look something like this: var x = 1.2; if (x == inteiro){ alert("x é um inteiro"); }     
asked by 14.11.2015 / 20:28
1
answer

Type Double and type Decimal

I found in the SO a question with an answer well accepted by the community # But I never had problems with double for monetary calculations, I had yes with float that already left my hair standing, then from this answer stating...
asked by 17.04.2015 / 20:14
1
answer

Type Int8 in Swift does not store the maximum integer 255

Doing some play on the Playground, With Swift 2.2 we can declare constant let testeIntOitoBits: Int8 = 127 //maximo - deveria ser 255 let testeIntOitoBits2: UInt8 = 255 Why can not I store 255 in type Int8 and in type UInt8 yes?     
asked by 18.06.2016 / 01:36
3
answers

Assign type to array in PHP

I know that PHP is a poorly typed language. But is there any alternative way to "type" a array in PHP? Example, I can do this below to force a given data type to be given in a function. function exemplo(Classe $valor){ // meu cód...
asked by 04.02.2015 / 19:54
1
answer

Meaning of (void *)

What does it mean to call a function with one that was int and is passed as (void *) ? If the variable was declared as int because it is passed as a parameter to a *(void *)variavel* function? Example int var =...
asked by 20.05.2014 / 21:26
1
answer

Simulate the Boolean type in C

What is the most appropriate way to simulate type bool in C? My teacher did it quite simply. #define bool int But I also found an excellent answer aqui ( follows a copy of the code). // Criando a enumeração: enum boolean { tr...
asked by 01.11.2015 / 15:48